开拓者TB CXH99反应趋势交易系统(RTS)即The Reaction Trend System 源码 [开拓者 TB]
- 最近市场可能比较震荡,农产品有许多震荡交易系统比较适用!所以在研究反应趋势交易系统(RTS)即The Reaction Trend System 由J.WELLES WILDER发明。本人粗糙简略地写了下代码:
- Params
- Numeric NumATRs(1);
- Numeric ATRLength(10);
- //Track Stop Profit or Loss
- Numeric StopATRLength(10);
- Numeric StopLossPcnt(3); //价格止损控制
- Numeric InitialStop(2); // 初始止损
- Numeric BreakEvenStop(2); // 保本止损
- Numeric TrailStop(2); // 追踪止损,回撤ATR的倍数
- //PriceOffset
- Numeric Offset(10);
- Vars
- NumericSeries TPrice;
- //Track Stop Loss or Profit
- NumericSeries HigherAfterEntry;
- NumericSeries LowerAfterEntry;
- NumericSeries HighestAfterEntry;
- NumericSeries LowestAfterEntry;
- BoolSeries bLongTrailingStoped;
- BoolSeries bShortTrailingStoped;
- Numeric MyExitPrice; // Exit Market Price
- //Stop Position
- Numeric MyPrice;
- Numeric MinPoint; // 一个最小变动单位,也就是一跳
- Numeric StopLine;
- Numeric StopLossBuffSet(15); //止损位Buffer
- NumericSeries ATRValue; //记录ATR值
- Numeric PriceOffset; //Buy or Sell Price Buffer
- //RTS Variables
- Numeric HBOP; //高价突破点
- Numeric LBOP; //低价突破点
- Numeric SellPoint; //卖点
- Numeric BuyPoint; //买点
- Begin
- //Price Offset
- PriceOffset = Offset * MinMove * PriceScale;
- //Track Stop Profit or Loss
- MinPoint = MinMove*PriceScale;
- ATRValue = AvgTrueRange(StopATRLength);
- // WWW.CXH99.COM
- //KeltnerChannel Variables
- TPrice = (High[1] + Low[1] + Close[1])/3;
- HBOP = 2 * TPrice - 2 * Low[1] + High[1];
- LBOP = 2 * TPrice - 2 * High[1] + Low[1];
- SellPoint = TPrice * 2 - Low[1]; // Sell Point
- BuyPoint = TPrice * 2 - High[1]; //Buy Point
- PlotNumeric("HBOP",HBOP);
- PlotNumeric("LBOP",LBOP);
- PlotNumeric("SellPoint", SellPoint);
- PlotNumeric("BuyPoint", BuyPoint);
- If (Open < HBOP And Open > LBOP)
- {
- //Long Futures High greater than UpperBand
- If(MarketPosition != 1 And High > BuyPoint)
- {
- MyPrice = BuyPoint;
- If(Open > MyPrice) MyPrice = Open;
- //Buy(1, Q_BidPrice + PriceOffset);
- //Buy(1, MyPrice + PriceOffset);
- SellShort(1, MyPrice - PriceOffset);
- }
- //Short Futures Low less than LowerBand
- If(MarketPosition != -1 And Low < SellPoint)
- {
- MyPrice = SellPoint;
- If(Open < MyPrice) MyPrice = Open;
- //SellShort(1, Q_AskPrice - PriceOffset);
- //SellShort(1, MyPrice - PriceOffset);
- Buy(1, MyPrice + PriceOffset);
- }
- } Else If(Open > HBOP) {
- //Long Futures High greater than UpperBand
- If(MarketPosition != 1)
- {
- MyPrice = HBOP;
- If(Open > MyPrice) MyPrice = Open;
- //Buy(1, Q_BidPrice + PriceOffset);
- Buy(1, MyPrice + PriceOffset);
- }
- } Else If(Open < LBOP) {
- //Short Futures Low less than LowerBand
- If(MarketPosition != -1)
- {
- MyPrice = LBOP;
- If(Open < MyPrice) MyPrice = Open;
- //SellShort(1, Q_AskPrice - PriceOffset);
- SellShort(1, MyPrice - PriceOffset);
- }
- }
- /* Set Loss Postion */
- MinPoint = MinMove * PriceScale;
- Myprice = EntryPrice * (1 - StopLossPcnt * 0.01);
- If(MarketPosition==1 and Low <= Myprice and BarsSinceEntry>0)
- {
- Myprice=Min(Myprice,Open);
- Sell(0, Myprice - stopLossBuffSet * MinPoint);
- Commentary("Price Pcnt Stop Loss");
- }
- Myprice = EntryPrice * (1 + StopLossPcnt * 0.01);
- If(MarketPosition==-1 and High>=Myprice and BarsSinceEntry>0)
- {
- Myprice=Max(Myprice,Open);
- BuyToCover(0, Myprice + stopLossBuffSet * MinPoint);
- Commentary("Price Pcnt Stop Loss");
- }
- /* Set Loss Postion */
- End
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 1145508240 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容