大伊人青草狠狠久久-大伊香蕉精品视频在线-大伊香蕉精品一区视频在线-大伊香蕉在线精品不卡视频-大伊香蕉在线精品视频75-大伊香蕉在线精品视频人碰人

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

新手請教公式設置 - TradeBlazer公式 [開拓者 TB]

  • 咨詢內容: // 自己新學TB,編了個公式卻不能實現,請高手們指導,謝謝。


    // 以下為均線交易系統,10日均線上穿20均線為買入,10日均線下穿20均線為賣出
    // 均線買入/賣出時機均為平倉反手
    // 開倉為二手,達到盈利預期值時平倉一手,等回落后加倉一手



    Params      
            Numeric Length1(10);        // 10日均線的參數值
            Numeric Length2(20);        // 20日均線的參數值
            Numeric Lots(2);            // 默認的交易數量  
    Vars        
            NumericSeries MA1;
            NumericSeries MA2;
            Numeric MinPoint; // 一個最小變動單位,也就是一跳
            Numeric AddSet(50); // 加倉設置
            Numeric SubSet(50); // 減倉設置
            NumericSeries FirstPrice; // 第一次開倉價格
            NumericSeries LastPrice; // 最后一次開倉價格
            boolSeries Condition1;
            boolSeries Condition2;
    Begin   
            MA1 = XAverage(Close,Length1);  
            MA2 = XAverage(Close,Length2);
            MinPoint = MinMove*PriceScale();
            Condition1 = CrossOver(MA1,MA2);
            Condition2 = CrossUnder(MA1,MA2);
            If(MarketPosition==0) //空倉狀態時
            {
            if(condition1[1])// 當出現10日均線上穿20均線時,下一個bar開盤價買入
            {
            FirstPrice = Open;
            LastPrice = FirstPrice;
            Buy(lots,FirstPrice);
            }else if(condition2[1]) // 當出現10日均線下穿20均線時,下一個bar開盤價賣出
            {
            FirstPrice = Open;
            LastPrice = FirstPrice;
            Sellshort(Lots,Open);  
            }
            }else if(MarketPosition==1) // 有多頭持倉的情況
            {
            If(condition2[1]) // 當出現10日均線下穿20均線時,下一個bar開盤價賣出
            {
            Sellshort(Lots,Open);
            }else if(CurrentContracts==2 && High>= LastPrice+SubSet*MinPoint) // 止贏減倉
            {
            Sell(1,LastPrice+SubSet*MinPoint);
            LastPrice =LastPrice + subSet*MinPoint;
            }else if(CurrentContracts==1 && Low <=LastEntryPrice - AddSet*MinPoint) // 逢低加倉
            {
            buy(1,LastPrice- AddSet*MinPoint);
            LastPrice = LastPrice - addSet*MinPoint;
            }
            }else if(MarketPosition==-1);// 有空頭持倉的情況
            {
            If(condition1[1]) // 當出現10日均線下穿20均線時,下一個bar開盤價平倉并買入
            {
            Sellshort(Lots,Open);
            }Else if(CurrentContracts==2 &&  Low <= LastEntryPrice - subSet*MinPoint) // 止贏減倉
            {
            BuyToCover(1,LastPrice);
            LastPrice = LastPrice - subSet*MinPoint;
            }else if( CurrentContracts==1 && High >=LastPrice + addSet*MinPoint) // 逢高加倉
            {
            sell(1,LastPrice);
            LastPrice = LastPrice + AddSet*MinPoint;
            }
            }
    End

     

  • TB技術人員: 好像是這樣吧


    // 以下為均線交易系統,10日均線上穿20均線為買入,10日均線下穿20均線為賣出
    // 均線買入/賣出時機均為平倉反手
    // 開倉為二手,達到盈利預期值時平倉一手,等回落后加倉一手



    Params      
            Numeric Length1(10);        // 10日均線的參數值
            Numeric Length2(20);        // 20日均線的參數值
            Numeric Lots(2);            // 默認的交易數量  
    Vars        
            NumericSeries MA1;
            NumericSeries MA2;
            Numeric MinPoint; // 一個最小變動單位,也就是一跳
            Numeric AddSet(50); // 加倉設置
            Numeric SubSet(50); // 減倉設置
            NumericSeries FirstPrice; // 第一次開倉價格
            NumericSeries LastPrice; // 最后一次開倉價格
            boolSeries Condition1;
            boolSeries Condition2;
    Begin   
            MA1 = XAverage(Close,Length1);  
            MA2 = XAverage(Close,Length2);
            MinPoint = MinMove*PriceScale();
            Condition1 = CrossOver(MA1,MA2);
            Condition2 = CrossUnder(MA1,MA2);
            If(MarketPosition!=1) //空倉狀態時
            {
            if(condition1[1])// 當出現10日均線上穿20均線時,下一個bar開盤價買入
            {
            FirstPrice = Open;
            LastPrice = FirstPrice;
            Buy(lots,FirstPrice);
            }
                    if(MarketPosition!=-1 and condition2[1]) // 當出現10日均線下穿20均線時,下一個bar開盤價賣出
            {
            FirstPrice = Open;
            LastPrice = FirstPrice;
            Sellshort(Lots,Open);  
            }
            }
                    if(MarketPosition==1) // 有多頭持倉的情況
            {
            If(condition2[1]) // 當出現10日均線下穿20均線時,下一個bar開盤價賣出
            {
            Sellshort(Lots,Open);
            }else if(CurrentContracts>1  and CurrentContracts<3  && High>= LastPrice+SubSet*MinPoint) // 止贏減倉
            {
            Sell(1,LastPrice+SubSet*MinPoint);
            LastPrice =LastPrice + subSet*MinPoint;
            }else if(CurrentContracts<2 && Low <=LastEntryPrice - AddSet*MinPoint) // 逢低加倉
            {
            buy(1,LastPrice- AddSet*MinPoint);
            LastPrice = LastPrice - addSet*MinPoint;
            }
            }
                    if(MarketPosition==-1);// 有空頭持倉的情況
            {
            If(condition1[1]) // 當出現10日均線下穿20均線時,下一個bar開盤價平倉并買入
            {
            Sellshort(Lots,Open);
            }Else if(CurrentContracts>1 and CurrentContracts<3  &&  Low <= LastEntryPrice - subSet*MinPoint) // 止贏減倉
            {
            BuyToCover(1,LastPrice);
            LastPrice = LastPrice - subSet*MinPoint;
            }else if( CurrentContracts<2 && High >=LastPrice + addSet*MinPoint) // 逢高加倉
            {
            sell(1,LastPrice);
            LastPrice = LastPrice + AddSet*MinPoint;
            }
            }
    End

     

  • TB客服: 謝謝,不過好像還是沒達到想要的效果

     

  • 網友回復: 回復 3# 青木


    您的效果是想要怎樣的?
    您可以將各個條件用commentary輸出查看你的條件,一步一步看就知道為什么不是你想要的效果了。
    commentary的各種使用方法請看:http://tradeblazer.net/forum/vie ... B%E4%BD%BF%E7%94%A8
    或者參考幫助文檔中相關函數說明

     

  • 網友回復: 回復 4# lh948

    這個建議非常好,謝謝!
    我按照你的方法把公式調整了,效果出來了。不過奇怪的是有多單時符合預期效果,但惟獨有空單時不能止贏和補倉,只能平倉反手。
    多單和空單的代碼是同理的,為何效果不同捏?
    以下是我修改會的代碼,請幫忙看看:

    // 以下為均線交易系統,10日均線上穿20均線為買入,10日均線下穿20均線為買出
    Params      
            Numeric Length1(10);        // 10日均線的參數值
            Numeric Length2(20);        // 20日均線的參數值
            Numeric Lots(2);            // 默認的交易數量  
    Vars        
            NumericSeries MA1;
            NumericSeries MA2;
            Numeric MinPoint(1); // 一個最小變動單位,也就是一跳
            Numeric AddSet(20); // 加倉設置
            Numeric SubSet(20); // 減倉設置
                    NumericSeries myFirstPrice; // 第一次開倉價格
                    NumericSeries myLastPrice; // 最后一次開倉價格
                    boolSeries Condition1;
                    boolSeries Condition2;
    Begin   
            MA1 = XAverage(Close,Length1);  
            MA2 = XAverage(Close,Length2);
            MinPoint = MinMove*PriceScale;
                    Condition1 = CrossOver(MA1,MA2);
            Condition2 = CrossUnder(MA1,MA2);
                    If(MarketPosition==0 )
                    {
                      if(condition1) //空倉狀態時出現10日均線上穿20均線,當前bar收盤價買入
                       {
                        myFirstPrice = Close;
                        myLastPrice = myFirstPrice;
                        Buy(lots,myFirstPrice);
                        Commentary("空倉狀態下,上穿20均線時,當前bar收盤價買入");
                       }Else if(condition2) // 空倉狀態時出現10日均線下穿20均線時,當前bar收盤價賣出
                       {
                        myFirstPrice = Close;
                        myLastPrice = myFirstPrice;
                Sellshort(Lots,myFirstPrice);
                Commentary("空倉狀態下,下穿20均線時,當前bar收盤價賣出");               
                       }
                    }Else if(MarketPosition==1 )
                       {
                        If(condition2) // 有多單持倉,出現10日均線下穿20均線時,當前bar收盤價賣出
                       {
                        myLastPrice = Close;
                        Sellshort(Lots,myLastPrice);
                            Commentary("多單平倉并反手");                 
                       }Else if(CurrentContracts==2 && High>= myLastPrice+SubSet*MinPoint) // 止贏減倉
                       {
                Sell(1,myLastPrice+SubSet*MinPoint);
                        Commentary("多單止贏1手");
                        myLastPrice =myLastPrice + subSet*MinPoint;
                       }Else if(CurrentContracts==1 && Low <=MA1) // 逢低加倉
               {
                buy(1,IntPart(MA1));
                        Commentary("多單補倉1手");
                    myLastPrice = IntPart(MA1);
                       }
            }Else If(MarketPosition==-1 )
               {
                        if(condition1)// 有空單持倉,出現10日均線上穿20均線時,當前bar收盤價平倉并買入
                       {
                        myLastPrice = Close;
                        Buy(Lots,myLastPrice);
                        Commentary("空單平倉并反手");
                       }Else if(CurrentContracts==2 && Low<=myLastPrice-SubSet*MinPoint) // 止贏減倉
               {
                        BuyToCover(1,myLastPrice-SubSet*MinPoint);
                        Commentary("空單止贏1手");
                        myLastPrice=myLastPrice-SubSet*MinPoint;
                       }Else if(CurrentContracts==1 && High>=MA1) // 逢高加倉
               {
                        sell(1,IntPart(MA1));
                            Commentary("空單補倉1手");               
                        myLastPrice = IntPart(MA1);
                       }
                       }
    End

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

相關文章

    沒有相關內容
主站蜘蛛池模板: 手机看片高清国产日韩片 | 波多野结衣中文字幕久久 | 欧美视频在线一区 | 就色干综合 | 中文字幕亚洲精品日韩精品 | 中文字幕99 | 亚洲国产精品久久日 | 色妞欧美 | 久久精品国产曰本波多野结衣 | 大乳欲妇三级一区二区三区 | 久久伊人一区二区三区四区 | 国产精品午夜波多野结衣性色 | 国产精品深爱在线 | 国产精品成aⅴ人片在线观看 | 欧美人与性动交α欧美精品图片 | 午夜精品在线免费观看 | 99精品国产成人a∨免费看 | 激情综合五月婷婷 | 四虎永久在线精品视频播放 | 国产在线麻豆精品 | 天天爱天天操 | 不卡在线| 免费一区二区 | 国产精品久久现线拍久青草 | 精品国产福利 | 免费视频久久看 | 久久爱992xxoo| 网友自拍视频悠悠在线 | 欧美视频免费在线播放 | 波多野结衣亚洲 | 国产成人精品午夜在线播放 | 国产精品久久久久久福利69堂 | 4hu永久影院在线四虎 | 性a爱片免费视频性 | 四虎影院在线视频 | 日本一级α一片免费视频 | 国内精品久久久久影院中国 | 天天做天天添天天谢 | 天堂成人av| 俺去鲁婷婷六月色综合 | 日韩国产午夜一区二区三区 |