ATR棘轮法 [文华财经]
- 咨询内容:
下面是TB的 ATR棘轮法,改成文化应如何写?谢谢,
Params
Numeric Lots(1); Numeric nOffset(3); Numeric HLength(5); Numeric LLength(5); Numeric AtrLength(0.05); Numeric myBarsSinceEntry(9);
Vars
NumericSeries HHH; NumericSeries LLL; NumericSeries HHH1; NumericSeries LLL1; NumericSeries Atr; Numeric myPrice; NumericSeries StopLine; NumericSeries LastPrice; Numeric MinPoint;
Begin
MinPoint = MinMove*PriceScale; HHH = Highest(High,HLength); LLL = Lowest(Low,LLength); HHH1 = Highest(High,10); LLL1 = Lowest(Low,10);
Atr = AvgTrueRange(20);
If(MarketPosition==1) { //LLL1 = Max(LLL1,LastPrice); LLL1 = Max(LLL1,LLL1[1]); //PlotNumeric("LLL1",LLL1);
If(BarsSinceEntry>myBarsSinceEntry || High>LastPrice+Atr[1]) { StopLine =Max(StopLine,LLL1[1] + (BarsSinceEntry)*Atr[1]*AtrLength); }
PlotNumeric("多头止损:",StopLine);
If(Low<StopLine) { myPrice =Min(Open,StopLine) - MinPoint*nOffset; Sell(Lots,myPrice);
} } If(MarketPosition==-1) { //HHH1 = Min(HHH1,LastPrice); HHH1 = Min(HHH1,HHH1[1]); //PlotNumeric("HHH1",HHH1);
If(BarsSinceEntry>myBarsSinceEntry || Low<LastPrice-Atr[1]) { StopLine =Min(StopLine,HHH1[1] - (BarsSinceEntry)*Atr[1]*AtrLength); } PlotNumeric("空头止损:",StopLine);
If(High>StopLine) { myPrice =Max(Open,StopLine) + MinPoint*nOffset; BuyToCover(Lots,myPrice);
} }
If(MarketPosition<>1) { If(High>HHH[1]) { myPrice =Max(Open,HHH[1]); Buy(Lots,myPrice +MinPoint*nOffset); LastPrice = myPrice; StopLine = myPrice -Atr[1]*1.5; Return; } } If(MarketPosition<>-1) { If(Low<LLL[1]) { myPrice = Min(Open,LLL[1]); SellShort(Lots,myPrice- MinPoint*nOffset); LastPrice = myPrice; StopLine = myPrice +Atr[1]*1.5; Return; } }
If(time == 0.1510) { Sell(Lots,Open -MinPoint*nOffset); BuyToCover(Lots,Open +MinPoint*nOffset); }
End
- 文华技术人员:
这样编写。
NOFFSET:=3;
HLENGTH:=5;
LLENGTH:=5;
ATRLENGTH:=0.05;
MYBARSSINCEENTRY:=9;
HHH:=HHV(HIGH,HLENGTH);
LLL:=LLV(LOW,LLENGTH);
HHH1:=HHV(HIGH,10);
LLL1:=LLV(LOW,10);
TR : MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATR : MA(TR,20),COLORYELLOW;
BKVOL>0&&(BARSBK>MYBARSSINCEENTRY||HIGH>BKPRICE+REF(ATR,1)),SP;
SKVOL>0&&(BARSSK>MYBARSSINCEENTRY||LOW<SKPRICE-REF(ATR,1)),BP;
TIME>=1510,CLOSEOUT;
AUTOFILTER;
注:您的源码中没有开仓条件,需要您自行定义下。
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 511411198 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容