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

開拓者突破型日內交易策略源碼 [開拓者 TB]

  • 源碼:


    Params   
            Numeric endTime(14.55);                    //結束交易時間
           Numeric RiskRatio(1);                       //風險率(0-100)
           Numeric boLength(18);                       //突破周期
           Numeric ATRLength(20);                      //平均波動周期
            Numeric Quitlength(10);                     //離市周期
            Numeric weightnumber(1);                    //加權參數
            Numeric Limitednumber(3);                   //交易限制次數(能交易的次數為limitednumber+1次)
        Bool Filtercondition(True);                 //入市過濾條件
    Vars
        Numeric Minpoint;                           //最小變動單位
            NumericSeries AvgTR;                        //ATR
            Numeric F;                                  //表示市場波動性的F值
            Numeric Capital;                            //入市資本
            Numeric scale;                              //買賣規模
            NumericSeries Passwayhi;                    //通道上軌{程序化交易}
            NumericSeries Passwaylo;                    //通道下軌
            NumericSeries quithighprice;                //離市時判斷需要的離市周期最高價
            NumericSeries quitlowprice;                 //離市時判斷需要的離市周期最低價
            Numeric myEntryPrice;                       //開倉價格
            Numeric myExitPrice;                        //平倉價格
            NumericSeries tempnum(0);                   //臨時計數器
            Bool Sendorderthisbar(False);               //當前Bar是否有過交易
            NumericSeries preEntryprice(0);             //前一次開倉的價格
    Begin
            Minpoint=Minmove*PriceScale;
            AvgTR=XAverage(TrueRange,ATRlength);
            F=weightnumber*AvgTR[1];
            Capital=Portfolio_CurrentCapital()+Portfolio_UsedMargin();
            scale=(Capital*RiskRatio/100)/(F*ContractUnit()*BigPointValue());
            scale=IntPart(scale);
            
            Passwayhi=HighestFC(High[1],boLength);
            Passwaylo=LowestFC(Low[1],boLength);
            
            quitlowprice=LowestFC(Low[1],Quitlength);
            quithighprice=HighestFC(High[1],Quitlength);
            
            Commentary("scale="+Text(scale));
            Commentary("preEntryprice="+Text(preEntryprice));
                   
            
            If(Date!=currentdate)                       //只限于當日交易{程序化交易}
            {return;}                                 
            If((Date!=Date[1])or(CurrentBar==0))
            {
            //當日的第一個Bar
            preEntryprice=InvalidNumeric;
            tempnum=Limitednumber;
            return;
            }
            
            If(tempnum[1]<1)
            {
            tempnum=limitednumber;
            }
            
            //開倉
    If(time<endtime/100)
    {        
            If(MarketPosition==0 And Filtercondition)
            {
                If(High>Passwayhi And scale>=1)
                    {
                    myEntryPrice=Min(high,passwayhi+minpoint);
                    myentryprice=IIF(myentryprice<open,open,myentryprice);
                    preentryprice=myentryprice;
                    Buy(scale,myentryprice);
                    sendorderthisbar=True;
                    }
                   
                    If(Low<passwaylo And scale>=1)
                    {
                    myentryprice=Max(low,passwaylo-Minpoint);
                    myentryprice=IIF(myentryprice>open,open,myentryprice);
                    preentryprice=myentryprice;
                    SellShort(scale,myentryprice);
                    sendorderthisbar=True;
                    }
            }
            
            
            If(Marketposition==1)
            {
                Commentary("quitlowprice="+Text(quitlowprice));
                    If(Low<quitlowprice)
                    {
                        myexitprice=Max(low,quitlowprice-Minpoint);
                            myexitprice=IIF(myexitprice>open,open,myexitprice);
                            Sell(0,myexitprice);
                            tempnum=limitednumber;
                    }Else
                    {
                        tempnum=tempnum[1];
                            If(preentryprice!=Invalidnumeric And scale>=1)
                            {
                                If((open>=preentryprice+0.5*F) And (tempnum>=1))
                                    {
                                        myentryprice=open;
                                            preentryprice=myentryprice;
                                            Buy(scale,myentryprice);
                                            sendorderthisbar=True;
                                            tempnum=tempnum-1;
                                    }
                                    
                                    While((High>=preentryprice+0.5*F) And (tempnum>=1))
                                    {
                                        myentryprice=preentryprice+0.5*F;
                                            preentryprice=myentryprice;
                                            Buy(scale,myentryprice);
                                            sendorderthisbar=true;
                                            tempnum=tempnum-1;
                                    }
                            }
                            
                            If(low<=preentryprice-2*F And sendorderthisbar==false)
                            {
                            myexitprice=preentryprice-2*F;
                            Sell(0,myexitprice);
                            tempnum=limitednumber;
                            }
                    }
            }Else If(marketposition==-1)
            {
                Commentary("quithighprice="+Text(quithighprice));
                    If(high>quithighprice)
                    {
                        myexitprice=Min(High,quithighprice+Minpoint);
                            myexitprice=IIF(myexitprice<open,open,myexitprice);
                            BuyToCover(0,myexitprice);
                            tempnum=limitednumber;
                    }Else
                    {   tempnum=tempnum[1];
                        If(preentryprice!=Invalidnumeric And scale>=1)
                            {
                                If((open<=preentryprice-0.5*F) And (tempnum>=1))
                                    {
                                        myentryprice=Open;
                                            preentryprice=myentryprice;
                                            SellShort(scale,myentryprice);
                                            sendorderthisbar=True;
                                            tempnum=tempnum-1;
                                    }
                                    
                                    While((Low<=preentryprice-0.5*F) And (tempnum>=1))
                                    {
                                        myentryprice=preentryprice-0.5*F;
                                            preentryprice=myentryprice;
                                            SellShort(scale,myentryprice);
                                            sendorderthisbar=True;
                                            tempnum=tempnum-1;
                                    }
                            }
                            
                            
                            If(High>=preentryprice+2*F And sendorderthisbar==False)
                            {
                                myexitprice=preentryprice+2*F;
                                    BuyToCover(0,myexitprice);
                                    tempnum=limitednumber;
                            }
                    }
            }
    }


            If(Time==0.145500 && /*CurrentTime>0.145800 &&*/ MarketPosition<>0)  //收盤平倉用于5Min
            {
                    Sell(0,Close);
                    BuyToCover(0,Close);
            
            }
            


    End

     

 

有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友

可聯系技術人員 QQ: 262069696  點擊在線交流進行 有償 編寫!不貴!點擊查看價格!


【字體: 】【打印文章】【查看評論

相關文章

    沒有相關內容
主站蜘蛛池模板: 蜜桃视频在线观看免费网址入口| 亚洲色偷偷色噜噜狠狠99| 91久久香蕉国产线看| 欧美人妻精品一区二区三区 | 中文字幕第一页国产| 男朋友想吻我腿中间的部位| 国产在线精品一区二区中文| 中文字幕中文字幕在线| 欧美一区二区三区激情视频| 国产婷婷综合在线视频| 中文无码乱人伦中文视频在线V| 欧美日本高清在线不卡区| 冈本视频老版app下载安装进入口| 黄色一级片免费看| 就去吻亚洲精品欧美日韩在线| 亚洲精品国产精品国自产观看| 被吃奶跟添下面视频| 婷婷六月天在线| 久久伊人中文字幕麻豆| 第一福利社区导航| 国产精品久久久久久一区二区三区 | 97在线观看视频| 成人免费午夜视频| 久久婷婷人人澡人人喊人人爽| 精品国产乱码一区二区三区麻豆| 在线欧美日韩精品一区二区| 亚洲av第一网站久章草| 特级毛片aaaa级毛片免费| 国产成人无码一区二区在线播放| 99久久免费精品国产72精品九九| 日韩精品一区二区三区在线观看 | 快穿之丁柔肉h暗卫温十三| 亚洲无码在线播放| 破处视频在线观看| 国产aⅴ精品一区二区三区久久| 国产精品入口在线看麻豆| 国产综合久久久久久鬼色| a网站在线观看| 成人麻豆日韩在无码视频| 久久国产精品张柏芝| 爽新片xxxxxxx|