老师,我想用这个指标作为高低价突破入场,以atr指标作为离场,要怎么编写,下面的公式做参考,
variable: xstop=0;
tr:=max(high-low,max(abs(high-ref(close,1)),abs(low-ref(close,1))));
atr:=sma(tr,20,1);
if high>=hhv(high,20) then xstop:=llv(low,10); {20日新高,建立多头停损价格起点——最近10日低点}
else if low>xstop then xstop:=xstop+0.05*atr; {多头延续,每天跟踪停损价格上移ATR的5%}
else if low<=llv(low,20) then xstop:=hhv(high,10);{20日新低,建立空头停损价格起点——最近10日高点}
else if high<xstop then xstop:=xstop - 0.05*atr;{空头延续,每天跟踪停损价格下移ATR的5%}
StopPrice: xstop;{显示停损价格}
你上面提供的代码。逻辑是不是有问题?你描述下你的需求。
if high>=hhv(high,20) // 不成立时xstop=0。
else if low>xstop //这个位置肯定成立了。
不明白你的意图。你自己整理下你的需求,要求怎么进行量化处理。需要你提供量化的思路