<address id="zhfln"></address>

    <form id="zhfln"></form>
    <address id="zhfln"><address id="zhfln"><listing id="zhfln"></listing></address></address>

        <form id="zhfln"><nobr id="zhfln"><progress id="zhfln"></progress></nobr></form>
        <sub id="zhfln"></sub>

        <sub id="zhfln"></sub>

          <form id="zhfln"><nobr id="zhfln"><meter id="zhfln"></meter></nobr></form>

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

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

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


          Params
                                  Numeric LongLength(20);                        // 長周期
                                  Numeric ShortLength(10);                // 短周期
                                  Numeric TrailingScale(0.5);                // 增倉比例
                                  Numeric StopLossSet(2);                        // 止損比例
                                  Numeric Lots(1);                                // 交易數量                               
          Vars
                                  Numeric MinPoint;                                // 最小變動單位
                                  NumericSeries AvgTR;                        // ATR
                                  Numeric N;                          // N 值
                                  NumericSeries DonchianHi;           // 唐奇安通道上軌,延后1個Bar
                                  NumericSeries DonchianLo;           // 唐奇安通道下軌,延后1個Bar
                                  Numeric ExitHighestPrice;           // 離市時判斷需要的N周期最高價
                                  Numeric ExitLowestPrice;            // 離市時判斷需要的N周期最低價
                                  Numeric myEntryPrice;               // 開倉價格
                                  Numeric myExitPrice;                // 平倉價格
                                  Bool SendOrderThisBar(False);   // 當前Bar有過交易
                                  NumericSeries preEntryPrice(0); // 前一次開倉的價格
          Begin
                                  If(BarStatus == 0)
                                  {
                                          preEntryPrice = InvalidNumeric;
                                  } Else
                                  {
                                          preEntryPrice = preEntryPrice[1];
                                  } //程序化交易 www.planetbokep.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); // 大跳空的時候用開盤價代替
                                          preEntryPrice = myEntryPrice;
                                          Buy(Lots,myEntryPrice);
                                          SendOrderThisBar = True;
                                  }
                                  If(MarketPosition == 0 && Low < DonchianLo)
                                  {
                                          myEntryPrice = max(low,DonchianLo);
                                          myEntryPrice = IIF(myEntryPrice > Open, Open,myEntryPrice); // 大跳空的時候用開盤價代替
                                          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); // 大跳空的時候用開盤價代替
                                                  Sell(0,myExitPrice);    // 數量用0的情況下將全部平
                                          }Else
                                          {
                                                  If(preEntryPrice!=InvalidNumeric)
                                                  {
                                                          If(Open >= preEntryPrice + TrailingScale*N) // 如果開盤就超過設定的1/2N,則直接用開盤價增倉。
                                                          {
                                                                  myEntryPrice = Open;
                                                                  preEntryPrice = myEntryPrice;
                                                                  Buy(Lots,myEntryPrice);
                                                                  SendOrderThisBar = True;
                                                          }       
                                                          while(High >= preEntryPrice + TrailingScale*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); // 大跳空的時候用開盤價代替
                                                          Sell(0,myExitPrice); // 數量用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); // 大跳空的時候用開盤價代替
                                                  BuyToCover(0,myExitPrice);    // 數量用0的情況下將全部平倉
                                          }Else
                                          {
                                                  If(preEntryPrice!=InvalidNumeric)
                                                  {
                                                          If(Open <= preEntryPrice - TrailingScale*N) // 如果開盤就超過設定的1/2N,則直接用開盤價增倉。
                                                          {
                                                                  myEntryPrice = Open;
                                                                  preEntryPrice = myEntryPrice;
                                                                  SellShort(Lots,myEntryPrice);
                                                                  SendOrderThisBar = True;
                                                          }
                                                          while(Low <= preEntryPrice - TrailingScale*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); // 大跳空的時候用開盤價代替
                                                  BuyToCover(0,myExitPrice); // 數量用0的情況下將全部平倉
                                          }
                                  }
                          }
          End

           

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

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

           


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

          相關文章

            沒有相關內容
            人妻专区免费视频,俄罗斯啪啪到高潮喷水,国色天香社区直播在线观看
            <address id="zhfln"></address>

            <form id="zhfln"></form>
            <address id="zhfln"><address id="zhfln"><listing id="zhfln"></listing></address></address>

                <form id="zhfln"><nobr id="zhfln"><progress id="zhfln"></progress></nobr></form>
                <sub id="zhfln"></sub>

                <sub id="zhfln"></sub>

                  <form id="zhfln"><nobr id="zhfln"><meter id="zhfln"></meter></nobr></form>