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

開拓者CXH99唐奇安通道交易策略源碼[開拓者公式]

開拓者CXH99唐奇安通道交易策略源碼


Params
                        Numeric LongLength(20);                        // 長周期
                        Numeric ShortLength(10);                // 短周期
                        Numeric TrailingScale(0.5);                // 增倉比例
                        Numeric StopLossSet(2);                        // 止損比例
                        Numeric Lots(1);                                // 交易數(shù)量                               
Vars
                        Numeric MinPoint;                                // 最小變動(dòng)單位
                        NumericSeries AvgTR;                        // ATR
                        Numeric N;                          // N 值
                        NumericSeries DonchianHi;           // 唐奇安通道上軌,延后1個(gè)Bar
                        NumericSeries DonchianLo;           // 唐奇安通道下軌,延后1個(gè)Bar
                        Numeric ExitHighestPrice;           // 離市時(shí)判斷需要的N周期最高價(jià)
                        Numeric ExitLowestPrice;            // 離市時(shí)判斷需要的N周期最低價(jià)
                        Numeric myEntryPrice;               // 開倉價(jià)格
                        Numeric myExitPrice;                // 平倉價(jià)格
                        Bool SendOrderThisBar(False);   // 當(dāng)前Bar有過交易
                        NumericSeries preEntryPrice(0); // 前一次開倉的價(jià)格
Begin
                        If(BarStatus == 0)
                        {
                                preEntryPrice = InvalidNumeric;
                        } Else
                        {
                                preEntryPrice = preEntryPrice[1];
                        } //程序化交易 www.tumamayizhan.com
       
                        AvgTR = XAverage(TrueRange,LongLength);
                        N = AvgTR[1];       
                        DonchianHi = HighestFC(High[1],LongLength);
                        DonchianLo = LowestFC(Low[1],LongLength);       
                        ExitLowestPrice = LowestFC(Low[1],ShortLength);
                        ExitHighestPrice = HighestFC(High[1],ShortLength);
                        Commentary("N="+Text(N));
                        Commentary("preEntryPrice="+Text(preEntryPrice));
                        PlotNumeric("上軌",DonchianHi);
                        PlotNumeric("下軌",DonchianLo);
                        PlotNumeric("退出上軌",ExitHighestPrice);
                        PlotNumeric("退出下軌",ExitLowestPrice);
                       
                        /*/////////////////////////////////開倉////////////////////////////////////////*/
                        If(MarketPosition == 0 && High > DonchianHi)
                        {
                                myEntryPrice = min(high,DonchianHi);
                                myEntryPrice = IIF(myEntryPrice < Open, Open,myEntryPrice); // 大跳空的時(shí)候用開盤價(jià)代替
                                preEntryPrice = myEntryPrice;
                                Buy(Lots,myEntryPrice);
                                SendOrderThisBar = True;
                        }
                        If(MarketPosition == 0 && Low < DonchianLo)
                        {
                                myEntryPrice = max(low,DonchianLo);
                                myEntryPrice = IIF(myEntryPrice > Open, Open,myEntryPrice); // 大跳空的時(shí)候用開盤價(jià)代替
                                preEntryPrice = myEntryPrice;
                                SendOrderThisBar = True;
                                SellShort(Lots,myEntryPrice);
                        }
                        /*///////////////////////////////止盈加倉////////////////////////////////////*/
                        If(MarketPosition == 1)
                        {      
                                Commentary("ExitLowestPrice="+Text(ExitLowestPrice));
                                If(Low < ExitLowestPrice)
                                {
                                        myExitPrice = max(Low,ExitLowestPrice);
                                        myExitPrice = IIF(myExitPrice > Open, Open,myExitPrice); // 大跳空的時(shí)候用開盤價(jià)代替
                                        Sell(0,myExitPrice);    // 數(shù)量用0的情況下將全部平
                                }Else
                                {
                                        If(preEntryPrice!=InvalidNumeric)
                                        {
                                                If(Open >= preEntryPrice + TrailingScale*N) // 如果開盤就超過設(shè)定的1/2N,則直接用開盤價(jià)增倉。
                                                {
                                                        myEntryPrice = Open;
                                                        preEntryPrice = myEntryPrice;
                                                        Buy(Lots,myEntryPrice);
                                                        SendOrderThisBar = True;
                                                }       
                                                while(High >= preEntryPrice + TrailingScale*N) // 以最高價(jià)為標(biāo)準(zhǔn),判斷能進(jìn)行幾次增倉
                                                {
                                                        myEntryPrice = preEntryPrice + TrailingScale * N;//程序化交易 www.chengxuhuajiaoyi.com
                                                        preEntryPrice = myEntryPrice;
                                                        Buy(Lots,myEntryPrice);
                                                        SendOrderThisBar = True;                                       
                                                }
                                        }                       
                                        /*///////////////////////////////////止損策略///////////////////////////////*/
                                        If(Low <= preEntryPrice - StopLossSet * N && SendOrderThisBar == false) // 加倉Bar不止損
                                        {
                                                myExitPrice = preEntryPrice - StopLossSet * N;
                                                myExitPrice = IIF(myExitPrice > Open, Open,myExitPrice); // 大跳空的時(shí)候用開盤價(jià)代替
                                                Sell(0,myExitPrice); // 數(shù)量用0的情況下將全部平倉
                                        }
                                } // www.chengxuhuajiaoyi.com
                        }Else If(MarketPosition ==-1) // 有空倉的情況
                        {
                                Commentary("ExitHighestPrice="+Text(ExitHighestPrice));
                                If(High > ExitHighestPrice)
                                {
                                        myExitPrice = Min(High,ExitHighestPrice);
                                        myExitPrice = IIF(myExitPrice < Open, Open,myExitPrice); // 大跳空的時(shí)候用開盤價(jià)代替
                                        BuyToCover(0,myExitPrice);    // 數(shù)量用0的情況下將全部平倉
                                }Else
                                {
                                        If(preEntryPrice!=InvalidNumeric)
                                        {
                                                If(Open <= preEntryPrice - TrailingScale*N) // 如果開盤就超過設(shè)定的1/2N,則直接用開盤價(jià)增倉。
                                                {
                                                        myEntryPrice = Open;
                                                        preEntryPrice = myEntryPrice;
                                                        SellShort(Lots,myEntryPrice);
                                                        SendOrderThisBar = True;
                                                }
                                                while(Low <= preEntryPrice - TrailingScale*N) // 以最低價(jià)為標(biāo)準(zhǔn),判斷能進(jìn)行幾次增倉
                                                {
                                                        myEntryPrice = preEntryPrice - TrailingScale * N;
                                                        preEntryPrice = myEntryPrice;
                                                        SellShort(Lots,myEntryPrice);
                                                        SendOrderThisBar = True;
                                                }
                                }
                                /*///////////////////////////////////止損策略///////////////////////////////*/
                                If(High >= preEntryPrice + StopLossSet * N && SendOrderThisBar==false) // 加倉Bar不止損
                                {
                                        myExitPrice = preEntryPrice + StopLossSet * N;
                                        myExitPrice = IIF(myExitPrice < Open, Open,myExitPrice); // 大跳空的時(shí)候用開盤價(jià)代替
                                        BuyToCover(0,myExitPrice); // 數(shù)量用0的情況下將全部平倉
                                }
                        }
                }
End

 

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

可聯(lián)系技術(shù)人員 QQ: 262069696  點(diǎn)擊在線交流進(jìn)行 有償 編寫!不貴!點(diǎn)擊查看價(jià)格!

 


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

相關(guān)文章

    沒有相關(guān)內(nèi)容
  主站蜘蛛池模板: 老王666天堂网站| mm1313亚洲精品国产| 污视频网站观看| 国产丰满麻豆vⅰde0sex| 99在线观看精品免费99| 日本五月天婷久久网站| 亚洲成a人片在线不卡| 精品国产理论在线观看不卡| 国产恋夜精品全部护士| 92国产精品午夜福利| 性高湖久久久久久久久| 亚洲AV无码乱码在线观看代蜜桃 | 精品国产免费一区二区三区香蕉| 国产无卡一级毛片aaa| 99久久国产免费-99久久国产免费| 无码欧精品亚洲日韩一区| 亚洲a级在线观看| 永久免费毛片在线播放| 动漫精品第一区二区三区| 高嫁肉柳风车动漫| 国产精品免费久久久久影院| japanese日本熟妇多毛| 新国产三级在线观看播放| 久久精品美女视频| 欧美挠脚心tickling免费| 丰满老熟好大bbb| 18日本xxxxxxxxx视频| 正在播放黑人巨大视频| 国产dvd毛片在线视频| 亚洲综合精品香蕉久久网| 女人与公狗交酡过程高清视频| 久久久久亚洲AV无码专区体验| 欧美专区在线播放| 亚洲色成人www永久网站| 精品真实国产乱文在线| 国产人妖cd网站| 激情黄+色+成+人| 国产精品无码久久综合| 99精品国产99久久久久久97| 性欧美丰满熟妇XXXX性久久久| 久久久精品波多野结衣AV|