画线漂移问题:
在画线工具中,里面有很多不同的画线类型,在下拉框里,找到"精确定位"打勾即可
可以考虑用全局变量,应该可以实现。比如海龟法则
上涨0.5*atr,开一次仓,最多开仓4次,即使同一个K线图出现连续开仓,也能记录,以下示例只做多。
variable:kc=0,buyp=0,stoploss=0;
atr:=ma(tr,20);//这里图方便,具体ATR的算法每5天算一次
hi20:=ref(hhv(h,20),1);
lo10:=ref(llv(l,10),1);
if h>hi20 and holding=0 then begin
buy(1,1,limitr,max(o,hi20)+5*mindiff);
buyp:=max(o,hi20);
kc:=kc+1;
stoploss:=buyp-2*atr;
end
for i=1 to 3 do begin
if h>buyp+0.5*atr and holding>0 and kc<4 then begin
buy(1,1,limitr,buyp+0.5*atr+5*mindiff);
buyp:=buyp+0.5*atr;
kc:=kc+1;
stoploss:=stoploss+0.5*atr;
end
end
if (l<lo10 or l<stoploss) and holding>0 then begin
sell(1,holding,limitr,min(o,lo10)-5*mindiff);
kc:=0;
end