您現(xiàn)在的位置:程序化交易>> 期貨公式>> 交易開拓者(TB)>> 開拓者知識(shí)>>正文內(nèi)容

TB公式中加倉問題 [開拓者 TB]

  • 咨詢內(nèi)容: 問題描述:
    1. 實(shí)盤操作加倉未成功(autotrade沒有加倉記錄,實(shí)際賬戶也沒有加倉記錄)
    2. 我在加倉操作前面加了日志,卻記錄很多加倉記錄
    本地記錄日志文件截取
    20160111 90005 Add Sell: Unit=2, Price=5495
    20160111 90005 Add Sell: Unit=2, Price=5495
    20160111 90006 Add Sell: Unit=2, Price=5495
    20160111 90006 Add Sell: Unit=2, Price=5495
    20160111 90007 Add Sell: Unit=2, Price=5495
    20160111 90007 Add Sell: Unit=2, Price=5495
    20160111 90008 Add Sell: Unit=2, Price=5495
    20160111 90008 Add Sell: Unit=2, Price=5495
    20160111 90009 Add Sell: Unit=2, Price=5495
    20160111 90009 Add Sell: Unit=2, Price=5495
    20160111 90010 Add Sell: Unit=2, Price=5495
    20160111 90010 Add Sell: Unit=2, Price=5495
    20160111 90011 Add Sell: Unit=2, Price=5495
    20160111 90011 Add Sell: Unit=2, Price=5495
    ....
    參數(shù)定義源碼
    Params
            Numeric LongLength(60);
            Numeric StopLossSet(20);
            Numeric AvgLen(20);                                                         // 高低點(diǎn)均線計(jì)算周期
            Numeric AbsDisp(5);                                                         // 高低點(diǎn)均線前移周期
            Numeric AddSet(10);        //加倉情況
            Numeric FirstUnit(1);
            Numeric AddUnit(2);
            Numeric MaxUnit(5);
            Numeric MaxLoss(2000);
            Numeric TradeOffset(1);                                                        //交易滑點(diǎn)
    Vars
            //NumericSeries UpperAvg(0);                                           // 通道上軌
            NumericSeries LowerAvg(0);                                           // 通道下軌
            NumericSeries LongMA(0);
            //NumericSeries ExitAvg(0);                                            // 通道中軌
            BoolSeries RangeLeadS(False);                                          // 是否RangeLead
            NumericSeries MedianPrice;                                             // K線中價(jià)
            NumericSeries range;                                                       // 振幅       
            NumericSeries HighestAfterEntry(0);
            NumericSeries LowestAfterEntry(0);
            Numeric MyPrice(0);
            NumericSeries MyLastPrice(0);
            NumericSeries MyUnit(0);
            String LogFileName;
            String Msg;
            Bool ShouldCover(False);

    加倉公式源代碼:
            // 系統(tǒng)入場(chǎng)
            //...省略代碼 參考 平移高低點(diǎn)均值通道與K線中值突破

            // 系統(tǒng)出場(chǎng)或加倉       
            If(MarketPosition == -1)             // 開倉后N根K線內(nèi)用中軌止損,N根K線后用上軌止損,N=參數(shù)ExitBar
            {
                    //初始化及計(jì)算動(dòng)態(tài)止盈
                    MyPrice=Open;
                    ShouldCover=False;
                   
                    if(BarsSinceEntry==0)
                    {
                            HighestAfterEntry=High;
                            LowestAfterEntry=Low;
                    }else
                    {
                            LowestAfterEntry = Min(LowestAfterEntry, Low);
                            HighestAfterEntry = Max(HighestAfterEntry, High);
                    }
                   
                    Commentary("LowestAfterEntry"+Text(LowestAfterEntry));
                    Commentary("HighestAfterEntry"+Text( HighestAfterEntry));
                   
                    //動(dòng)態(tài)止損線
                    If(BarsSinceEntry>0)
                    {
                            Commentary(" LowestAfterEntry[1]"+Text( LowestAfterEntry[1]));
                            PlotNumeric("DynamicStopLossLine", LowestAfterEntry[1]+StopLossSet);

                            //動(dòng)態(tài)止損
                            if(High>LowestAfterEntry[1]+StopLossSet)
                            {
                                    ShouldCover=True;
                                    MyPrice=LowestAfterEntry[1]+StopLossSet+TradeOffset;
                            }
                            //加倉
                            else if(Open<=MyLastPrice-AddSet and MyUnit<MaxUnit)
                            {
                                    MyUnit=MyUnit+AddUnit;
                                    MyLastPrice=Min(MyLastPrice-AddSet, Open-TradeOffset);
                                    Sellshort(AddUnit,MyLastPrice);
                           
                                    Msg="Add Sell: Unit="+Text(AddUnit)+", Price="+Text(MyLastPrice);
                                    LogMsg(Msg, BarStatus==2, LogFileName);
                            }
                    }
            }

    LogMsg函數(shù)源碼

    Params
            String Msg;
            Bool Enabled(false);
            String FileName("D:\\autotrade");
    Vars
            String LogTime;
            String Path("D:\\Autotrade\\Trade_");
    Begin
           
            Commentary(Msg);
            Path=Path+FileName+"_"+A_AccountID+"_"+Text(CurrentDate)+".log";
           
            IF(Enabled)
            {
                    LogTime=Text(CurrentDate)+" "+Text(CurrentTime*1000000)+" ";
                    FileAppend(Path, LogTime+Msg);
            }
            Return Msg;
    End

     

  • TB技術(shù)人員: 追加系統(tǒng)入場(chǎng)代碼
            // 集合競(jìng)價(jià)和小節(jié)休息過濾
            If(!CallAuctionFilter()) Return;
           
            LogFileName="My_K_V3_S_"+Symbol;
           
            // 指標(biāo)計(jì)算
            range = High - Low;
            //UpperAvg = Average(High[AbsDisp], AvgLen);          // 計(jì)算N周期前高點(diǎn)的MA,N=參數(shù)AbsDisp
            LowerAvg = Average(Low[AbsDisp], AvgLen);           // 計(jì)算N周期前低點(diǎn)的MA,N=參數(shù)AbsDisp
            LongMA=Average(C, LongLength);
            MedianPrice = (High + Low)*0.5;                     // 計(jì)算K線中點(diǎn)
           
            PlotNumeric("LowMA",LowerAvg);
            PlotNumeric("LongMA", LongMA);
            PlotNumeric("LowerAvg", LowerAvg);
           
            RangeLeadS = MedianPrice < Low[1] and Range > Range[1];   // 當(dāng)K線中點(diǎn)小于前一根K線低點(diǎn)并且振幅〉上一根振幅時(shí),RangeLeadS為真

            //策略退出條件
            if(NetProfit<=-MaxLoss)
            {
                    If(MarketPosition!=0)
                    {
                            ShouldCover=True;
                            MyPrice=Open+TradeOffset;
                    }
                    PlotBool("Failed", false);
            }
            // 系統(tǒng)入場(chǎng)
            Else If(MarketPosition == 0)
            {
                    If(RangeLeadS[1] and Close[1] < LowerAvg[1] and LowerAvg<LowerAvg[1] and LongMA[1]<LongMA[2] )                // 上根K線RangeLeadS為真,并且上一根收盤價(jià)小于N周期前低點(diǎn)的MA,當(dāng)前無空倉,則開空倉
                    {
                            MyUnit=FirstUnit;
                            MyLastPrice=Open-TradeOffset;
                            Sellshort(MyUnit, MyLastPrice);
                           
                            Msg="SellShort: Unit="+Text(MyUnit)+", Price="+Text(MyLastPrice);
                            LogMsg(Msg, BarStatus==2, LogFileName);
                    }
            }

     

  • TB客服: 麻煩高手指點(diǎn)下問題所在,非常感謝!

     

  • 網(wǎng)友回復(fù):
    sywg8011006110 發(fā)表于 2016-1-12 09:02
    麻煩高手指點(diǎn)下問題所在,非常感謝!

    先試一下在全局交易設(shè)置里設(shè)置為允許連續(xù)建倉,以及加倉次數(shù)設(shè)大一些,再看看信號(hào)有無加倉信號(hào)。

     

  • 網(wǎng)友回復(fù):
    小米 發(fā)表于 2016-1-12 13:41
    先試一下在全局交易設(shè)置里設(shè)置為允許連續(xù)建倉,以及加倉次數(shù)設(shè)大一些,再看看信號(hào)有無加倉信號(hào)。 ...

    請(qǐng)問我的日志文件重復(fù)記錄日志怎么解釋?

 

有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友

可聯(lián)系技術(shù)人員 QQ: 511411198  點(diǎn)擊這里給我發(fā)消息進(jìn)行 有償 編寫!不貴!點(diǎn)擊查看價(jià)格!


【字體: 】【打印文章】【查看評(píng)論

相關(guān)文章

    沒有相關(guān)內(nèi)容
主站蜘蛛池模板: 日韩电影免费在线观看网站| 美女免费精品高清毛片在线视 | 夜来香高清在线观看| 久久国产精品一国产精品金尊| 狍和女人一级毛片免费的| 国产va免费精品观看精品| 亚洲伊人久久网| 夜夜影院未满十八勿进| 中文字幕专区高清在线观看| 李丽莎1分37钞视频最大尺度| 亚洲色精品vr一区二区三区| 亚洲毛片基地4455ww| 日韩亚洲翔田千里在线| 亚洲精品动漫免费二区| 美女内射无套日韩免费播放| 国产成人www| 两个人的视频www免费| 最新中文字幕在线资源| 亚洲精品无码专区在线播放| 精品视频一区二区三三区四区| 国产网站在线播放| 一级国产a级a毛片无卡| 日本电影一区二区三区| 亚洲国产成人va在线观看网址| 男男肉动漫未删减版在线观看| 国产一区在线观看视频| 免费人成在线观看69式小视频| 国精无码欧精品亚洲一区| yellow中文字幕在线高清| 欧美中文字幕在线视频| 国产V亚洲V天堂无码久久久| 免费在线观看h片| 国产精品第九页| 99精品视频99| 少妇被又大又粗又爽毛片| 久久久久亚洲AV成人无码| 最新中文字幕av专区| 亚洲午夜精品一区二区| 污污视频在线观看黄| 人妻av无码专区| 精品国产一区二区三区AV性色|