人人爽天天爽夜夜爽qc-人人爽天天爽夜夜爽曰-人人天天爱天天做天天摸-人人天天夜夜-色网站在线-色网站在线看

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

大師們幫我看看如何修改策略(RSI做多策略) [開拓者 TB]

  • 咨詢內容: 策略思路:
       RSI 多頭策略
      1 多頭入場: RSI 上破55, 在下一根Bar開盤價入場。
      2 多頭出場: RSI下破45,在下一根bar 開盤價出場。
    3 保護性止損: 當價格下破 進場價減一定倍數(初始值為1)的ATR時,止損出場。
    4 跟蹤止盈(止損): 多頭入場后,記錄入場后最高點,然后在價格下破 最高點減 一定倍數ATR( 初始值設定為1時) 止盈(止損)出場

    另外,如果策略想加上一個再進場,止損后,如果價格突破10日高點,再進場,要怎么寫。。。

    初學階段,自己改了幾次,越改越不對路了。 只好向大師求教。。。

    Params
            Numeric Length(14) ;
            Numeric DnTrend(45) ;
            Numeric UpTrend(55);
            Numeric Lots(0);
            Numeric CoATR(1);
            Numeric ATRLength(14);
            Numeric TrailStopCoATR(1);
           
    Vars
            NumericSeries NetChgAvg( 0 );
            NumericSeries TotChgAvg( 0 );
            Numeric SF( 0 );
            NumericSeries Change( 0 );       
            NumericSeries ChgRatio( 0 ) ;
            NumericSeries RSIValue;
            NumericSeries ProtectStopLoss(0);
            NumericSeries HighestAfterEntry(0);
            NumericSeries TrailStopLine(0);
           
    Begin
            // 集合競價和小節休息過濾
                    If(!CallAuctionFilter()) Return;
                   
            If(CurrentBar <= Length - 1)
            {
                    NetChgAvg = ( Close - Close[Length] ) / Length ;
                    TotChgAvg = Average( Abs( Close - Close[1] ), Length ) ;
            }Else
            {
                    SF = 1/Length;
                    Change = Close - Close[1] ;
                    NetChgAvg = NetChgAvg[1] + SF * ( Change - NetChgAvg[1] ) ;
                    TotChgAvg = TotChgAvg[1] + SF * ( Abs( Change ) - TotChgAvg[1] ) ;       
            }
           
            If( TotChgAvg <> 0 )
            {
                    ChgRatio = NetChgAvg / TotChgAvg;
            }else
            {
                    ChgRatio = 0 ;
            }       
            RSIValue = 50 * ( ChgRatio + 1 );       
            PlotNumeric("RSI",RSIValue);
            PlotNumeric("UpTrend",UpTrend);
            PlotNumeric("DnTrend",DnTrend);       
           
           
            If (MarketPosition<>1&& RSIValue[1]>UpTrend)
            {
            Buy(Lots,Open);
            ProtectStopLoss=LastEntryPrice-CoATR*AvgTrueRange(ATRLength);
            }
            Commentary("rotectStopLoss"+Text(ProtectStopLoss));
            If(MarketPosition==1&&BarsSinceEntry>0)
            {       
            If (Low<=ProtectStopLoss)
            {
            Sell(0,Min(Open,ProtectStopLoss));
            Commentary("rotectStop");
            }
            }
            If (BarsSinceEntry==0)
            HighestAfterEntry=High;
            Else
            HighestAfterEntry=Max(HighestAfterEntry[1],High);       
            TrailStopLine=HighestAfterEntry-TrailStopCoATR*AvgTrueRange(ATRLength);
            Commentary("TrailStopLine"+Text(TrailStopLine));
            If (MarketPosition==1&&BarsSinceEntry>0)
            {       
            If(Low<=TrailStopLine[1])
            {
            Sell(0,Min(Open,TrailStopLine[1]));
            Commentary("TrailStop");       
            }
            }
            If(MarketPosition==1&&BarsSinceEntry>0)
            {
            If(RSIValue[1]<DnTrend)
            {
            Sell(0,Open);
            Commentary("反手出場");
            }
            }
    End

     

  • TB技術人員: 本帖最后由 Allin9999 于 2016-1-25 16:21 編輯

    在你的代碼基礎上做了一些修改,供你參考。再進場部分我就按照方便處理的原則簡化處理了,假定RSI跌破UpTrend,就不算再進場了。這個具體寫的時候還是要根據自己的策略進行調整。
    1. Params
    2.         Numeric Length(14) ;
    3.         Numeric DnTrend(45) ;
    4.         Numeric UpTrend(55);
    5.         Numeric Lots(0);
    6.         Numeric CoATR(1);
    7.         Numeric ATRLength(14);
    8.         Numeric TrailStopCoATR(1);
    9.         
    10. Vars
    11.         NumericSeries NetChgAvg( 0 );
    12.         NumericSeries TotChgAvg( 0 );
    13.         Numeric SF( 0 );
    14.         NumericSeries Change( 0 );        
    15.         NumericSeries ChgRatio( 0 ) ;
    16.         NumericSeries RSIValue;
    17.         NumericSeries ProtectStopLoss(0);
    18.         NumericSeries HighestAfterEntry(0);
    19.         NumericSeries TrailStopLine(0);

    20.         NumericSeries AtrValue;
    21.         Numeric RangeHigh;
    22.         
    23. Begin
    24.         // 集合競價和小節休息過濾
    25.         If(!CallAuctionFilter()) Return;
    26.                
    27.         If(CurrentBar <= Length - 1)
    28.         {
    29.                 NetChgAvg = ( Close - Close[Length] ) / Length ;
    30.                 TotChgAvg = Average( Abs( Close - Close[1] ), Length ) ;
    31.         }Else
    32.         {
    33.                 SF = 1/Length;
    34.                 Change = Close - Close[1] ;
    35.                 NetChgAvg = NetChgAvg[1] + SF * ( Change - NetChgAvg[1] ) ;
    36.                 TotChgAvg = TotChgAvg[1] + SF * ( Abs( Change ) - TotChgAvg[1] ) ;        
    37.         }
    38.         
    39.         If( TotChgAvg <> 0 )
    40.         {
    41.                 ChgRatio = NetChgAvg / TotChgAvg;
    42.         }else
    43.         {
    44.                 ChgRatio = 0 ;
    45.         }        
    46.         RSIValue = 50 * ( ChgRatio + 1 );        
    47.         PlotNumeric("RSI",RSIValue);
    48.         PlotNumeric("UpTrend",UpTrend);
    49.         PlotNumeric("DnTrend",DnTrend);        
    50.         

    51.         AtrValue = AvgTrueRange(ATRLength);
    52.         Commentary("AtrValue="+Text(AtrValue));

    53.         RangeHigh = Highest(H[1],10);
    54.                
    55.         If(MarketPosition<>1 && RSIValue[2] < UpTrend And RSIValue[1]>UpTrend)
    56.         {
    57.                 Buy(Lots,Open);
    58.                 ProtectStopLoss=LastEntryPrice-CoATR*AtrValue;
    59.         }
    60.         Else If(MarketPosition<>1 And High >= RangeHigh And RSIValue[1]>UpTrend)
    61.         {
    62.                 Buy(Lots,Max(Open,RangeHigh));
    63.                 ProtectStopLoss=LastEntryPrice-CoATR*AtrValue;
    64.         }
    65.         Commentary("ProtectStopLoss"+Text(ProtectStopLoss));

    66.         If(MarketPosition==1 && BarsSinceEntry>0)
    67.         {
    68.                 If(RSIValue[1]<DnTrend)
    69.                 {
    70.                         Sell(0,Open);
    71.                         Commentary("反手出場");
    72.                 }
    73.         }
    74.                
    75.         If(MarketPosition==1 && BarsSinceEntry>0)
    76.         {
    77.                 If (Low<=ProtectStopLoss)
    78.                 {
    79.                         Sell(0,Min(Open,ProtectStopLoss));
    80.                         Commentary("ProtectStop");
    81.                 }
    82.         }
    83.                
    84.         If (BarsSinceEntry==0)
    85.                 HighestAfterEntry=High;
    86.         Else
    87.                 HighestAfterEntry=Max(HighestAfterEntry[1],High);
    88.                        
    89.         TrailStopLine = HighestAfterEntry - TrailStopCoATR*AtrValue;

    90.         Commentary("TrailStopLine"+Text(TrailStopLine));

    91.         If(MarketPosition==1&&BarsSinceEntry>0)
    92.         {        
    93.                 If(Low<=TrailStopLine[1])
    94.                 {
    95.                         Sell(0,Min(Open,TrailStopLine[1]));
    96.                         Commentary("TrailStop");        
    97.                 }
    98.         }
    99.                
    100. End
    復制代碼

     

  • TB客服:
    Allin9999 發表于 2016-1-25 16:19
    在你的代碼基礎上做了一些修改,供你參考。再進場部分我就按照方便處理的原則簡化處理了,假定RSI跌破UpTre ...

    非常感謝!!

 

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

可聯系技術人員 QQ: 511411198  點擊這里給我發消息進行 有償 編寫!不貴!點擊查看價格!


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

相關文章

    沒有相關內容
主站蜘蛛池模板: 免看一级a一片成人123 | 色啊色 | 亚洲一区二区三区精品国产 | 久久综合久久综合久久综合 | 无码日韩精品一区二区免费 | 一级特级aaaa毛片免费观看 | 看片在线观看免费 | 九色福利| 色在线免费 | 欧美日韩精品在线观看 | 伊人五月 | www.色黄| 三级大片网站 | 免费色黄网站 | 免费看黄无遮挡滚床单视频 | 日日狠狠久久偷偷四色综合免费 | 中中文字幕亚州无线码 | 超人碰碰碰人人成碰人 | 欧美一级成人 | 手机看片a永久免费看大片 手机看片91精品一区 | 成在线人视频免费视频 | 国产中文字幕乱人伦在线观看 | 天天躁狠狠躁狠狠躁夜夜躁 | 天天综合天天看夜夜添狠狠玩 | 春意影院午夜爽爽爽免费 | 国产精品一库二库三库 | 在线毛片免费 | 国产精品手机在线亚洲 | 欧美人成网站在线看 | 涩涩逼| 成年午夜性爽快免费视频不卡 | 成人羞羞| 日本欧美一区 | 亚洲免费区 | 黄色片免费在线观看 | 精品国产一区二区三区www | 精品在线观看一区 | 中国护士一级毛片免费版本 | 久久精品视频6 | 免费一级毛片在线观看 | 色婷婷综合久久久中文字幕 |