variable:bsstatus=0,bsprice=0,bsline=0;
......
......
if (tholding2=-1) then
begin
if c>=bsprice then
sellshort(1=1,0,limit,c-0.4);
if bsline>c then
begin
bsline := c;
bsprice:= bsline +m;
end;
end;
bsstatusshow:bsstatus,linethick0;
holdingshow:tholding2,linethick0;
bspriceshow:bsprice,linethick0,colorred;
bslineshow:bsline,linethick0,colorred;
bsc:c,linethick0,colorred;
我开了个空仓,以上代码中,variable变量:bsline应该是最低价线,但实际运行中bsline与C是在同步变化的。这是为什么
这个例子是虚拟仓位的例子,我希望做的是根据实际仓位情况来判断。思路很简单,就是从开仓点价格开始,5个点回调的移动止损止赢。
现在是问题其实是variable变量的问题,这种变量在每次指标调用都被初始化了,可能要换成另一种形式的全局变量,不随指标调用变化。
if cond then buy(1,1,market);
if ENTERPRICE-5*mindiff>c then sell(1,0,market);
可以不要用全局变量啊