開拓者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.kzuj.com.cn
- //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 進行 有償 編寫!(不貴!點擊查看價格!)
相關文章
-
沒有相關內容