目前是我想编写跟踪止损,以开多后最高价向下的1%价格为止损点。
但是编写以下公式后,很多都是一开多之后,后一根k线就平多,我探究原因是因为其最高价是enterbars即使是在空仓时也是存在的,在开多之后的一个周期以内,最高价是以上一个开仓以来的最高价格为标准,但目前我并不知道如何更改,改了几次并没有什么效果。
请帮忙写一下,谢谢
highprice:=ref(hhv(c,enterbars),1);
if holding>0 and enterbars>0 then begin
pz2:=highprice-c>0.01*highprice,noaxis;
end
IF holding>0 and pz2 THEN BEGIN
sell(1,holding,market);
END
if tenterbars>0 and (hhv(c,enterbars-close)) /hhv(c,enterbars) >0.01 then sell()