设为首页收藏本站

 找回密码
 注册
查看: 7446|回复: 3
打印 上一主题 下一主题

反应趋势交易系统(RTS) [复制链接]

Rank: 4

精华
0
UID
115197
积分
307
帖子
23
主题
9
阅读权限
50
注册时间
2013-1-28
最后登录
2018-8-6
跳转到指定楼层
1#
发表于 2013-5-16 14:12:15 |只看该作者 |倒序浏览
本帖最后由 duck_arrow 于 2014-10-29 13:33 编辑

最近市场可能比较震荡,农产品有许多震荡交易系统比较适用!所以在研究反应趋势交易系统(RTS)即The Reaction Trend System 由J.WELLES WILDER发明。本人粗糙简略地写了下代码:
  1. Params
  2.         Numeric NumATRs(1);
  3.         Numeric ATRLength(10);
  4.         //Track Stop Profit or Loss
  5.         Numeric StopATRLength(10);
  6.         Numeric StopLossPcnt(3);     //价格止损控制
  7.         Numeric InitialStop(2);     // 初始止损          
  8.         Numeric BreakEvenStop(2);   // 保本止损         
  9.         Numeric TrailStop(2);       // 追踪止损,回撤ATR的倍数       
  10.         //PriceOffset
  11.         Numeric Offset(10);       
  12. Vars
  13.         NumericSeries TPrice;
  14.         //Track Stop Loss or Profit
  15.         NumericSeries HigherAfterEntry;
  16.         NumericSeries LowerAfterEntry;
  17.         NumericSeries HighestAfterEntry;
  18.         NumericSeries LowestAfterEntry;
  19.         BoolSeries          bLongTrailingStoped;
  20.         BoolSeries          bShortTrailingStoped;
  21.         Numeric       MyExitPrice;                          // Exit Market Price
  22.         //Stop Position
  23.         Numeric       MyPrice;
  24.         Numeric       MinPoint;               // 一个最小变动单位,也就是一跳
  25.         Numeric       StopLine;
  26.         Numeric       StopLossBuffSet(15);    //止损位Buffer
  27.         NumericSeries ATRValue;               //记录ATR值
  28.         Numeric       PriceOffset;                          //Buy or Sell Price Buffer
  29.         //RTS Variables
  30.         Numeric HBOP;  //高价突破点
  31.         Numeric LBOP;  //低价突破点
  32.         Numeric SellPoint;  //卖点
  33.         Numeric BuyPoint;  //买点
  34. Begin
  35.         //Price Offset
  36.         PriceOffset = Offset * MinMove * PriceScale;
  37.        
  38.         //Track Stop Profit or Loss
  39.         MinPoint = MinMove*PriceScale;
  40.         ATRValue = AvgTrueRange(StopATRLength);
  41.        
  42.         //KeltnerChannel Variables
  43.         TPrice = (High[1] + Low[1] + Close[1])/3;
  44.         HBOP = 2 * TPrice - 2 * Low[1] + High[1];
  45.         LBOP = 2 * TPrice - 2 * High[1] + Low[1];
  46.         SellPoint = TPrice * 2 - Low[1];   // Sell Point
  47.         BuyPoint = TPrice * 2 - High[1]; //Buy Point

  48.         PlotNumeric("HBOP",HBOP);
  49.         PlotNumeric("LBOP",LBOP);
  50.         PlotNumeric("SellPoint", SellPoint);
  51.         PlotNumeric("BuyPoint", BuyPoint);
  52.        
  53.         If (Open < HBOP And Open > LBOP)
  54.         {
  55.                 //Long Futures High greater than UpperBand
  56.                 If(MarketPosition != 1 And High > BuyPoint)
  57.                 {
  58.                         MyPrice = BuyPoint;
  59.                         If(Open > MyPrice) MyPrice = Open;
  60.                         //Buy(1, Q_BidPrice + PriceOffset);
  61.                         //Buy(1, MyPrice + PriceOffset);
  62.                         SellShort(1, MyPrice - PriceOffset);
  63.                 }
  64.                 //Short Futures Low less than LowerBand
  65.                 If(MarketPosition != -1 And Low < SellPoint)
  66.                 {
  67.                         MyPrice = SellPoint;               
  68.                         If(Open < MyPrice) MyPrice = Open;
  69.                         //SellShort(1, Q_AskPrice - PriceOffset);
  70.                         //SellShort(1, MyPrice - PriceOffset);
  71.                         Buy(1, MyPrice + PriceOffset);
  72.                        
  73.                 }
  74.                
  75.         }  Else If(Open > HBOP) {
  76.                 //Long Futures High greater than UpperBand
  77.                 If(MarketPosition != 1)
  78.                 {
  79.                         MyPrice =  HBOP;
  80.                         If(Open > MyPrice) MyPrice = Open;
  81.                         //Buy(1, Q_BidPrice + PriceOffset);
  82.                         Buy(1, MyPrice + PriceOffset);
  83.                 }
  84.         } Else If(Open < LBOP) {
  85.                 //Short Futures Low less than LowerBand
  86.                 If(MarketPosition != -1)
  87.                 {
  88.                         MyPrice = LBOP;               
  89.                         If(Open < MyPrice) MyPrice = Open;
  90.                         //SellShort(1, Q_AskPrice - PriceOffset);
  91.                         SellShort(1, MyPrice - PriceOffset);
  92.                 }       
  93.         }

  94.         /* Set Loss Postion */
  95.         MinPoint = MinMove * PriceScale;
  96.         Myprice = EntryPrice * (1 - StopLossPcnt * 0.01);
  97.         If(MarketPosition==1 and Low <= Myprice and BarsSinceEntry>0)
  98.         {
  99.                 Myprice=Min(Myprice,Open);
  100.                 Sell(0, Myprice - stopLossBuffSet * MinPoint);
  101.                 Commentary("Price Pcnt Stop Loss");
  102.         }
  103.         Myprice = EntryPrice * (1 + StopLossPcnt * 0.01);
  104.         If(MarketPosition==-1 and High>=Myprice and BarsSinceEntry>0)
  105.         {
  106.                 Myprice=Max(Myprice,Open);
  107.                 BuyToCover(0, Myprice + stopLossBuffSet * MinPoint);
  108.                 Commentary("Price Pcnt Stop Loss");
  109.         }
  110.         /* Set Loss Postion */
  111. End
复制代码
代码中应该还需要计算Buy Day(B), Sell Dya(S), 还有Oday。但是不知道如何计算得出当前Bar应该是 B or S or O。如果得出当前Bar是 B就做Long操作。如果是S就做Short操作。本人在恒温器策略中得到启示见原帖:http://bbs.tb18.net/thread-24916-1-1.html
恒温器中是这样确定的。
                keyofday=(HighD(0)+LowD(0)+CloseD(0))/3;
                If(Date<>Date[1]){
                If(CloseD(1)>keyofday[1])
                {
                selleasierday=1;//空头日
                }Else{
                buyeasierday=1;//多头日
                }
希望大家给点建议!!!

Rank: 4

精华
0
UID
50057
积分
304
帖子
175
主题
17
阅读权限
50
注册时间
2011-6-27
最后登录
2015-1-4
2#
发表于 2013-5-16 18:30:06 |只看该作者
先顶了 再看

使用道具 举报

Rank: 4

精华
0
UID
71944
积分
376
帖子
76
主题
22
阅读权限
50
注册时间
2011-10-16
最后登录
2020-2-8
3#
发表于 2013-5-17 06:33:52 |只看该作者
牛!

使用道具 举报

Rank: 4

精华
0
UID
218974
积分
322
帖子
265
主题
17
阅读权限
50
注册时间
2015-9-5
最后登录
2023-5-7
4#
发表于 2016-7-17 11:34:15 |只看该作者
不理想

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

bottom

静态版|手机版|联系我们|交易开拓者 ( 粤ICP备07044698   

GMT+8, 2024-5-2 18:24

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部