思路:
1:空仓情况下(2个常量:X/Y)
收盘价上穿X开多,如果收盘前下破X平多,否则持多仓过夜;
收盘价下破Y开空,如果收盘前上穿Y平空,否则持空仓过夜;
2:持仓情况下(2个常量:X/Y)
持多仓:
收盘价下破Y平多开空,如果收盘前上穿Y平空开多,否则持空仓过夜;
持空仓:
收盘价上穿X平空开多,如果收盘前下穿X平多开空,否则持多仓过夜;
谢谢您!
if holding=0 and cross(close,x) then begin
buy(1,1,market);
end
if cross(x,close) and holding>0 then begin
sell(1,0,market);
end
if holding=0 and cross(y,close) then begin
buyshort(1,1,market);
end
if holding<0 and cross(close,y) then begin
sellshort(1,0,market);
end
if holding>0 and cross(y,close) then begin
sell(1,0,market);
buyshort(holding=0,1,market);
end
if cross(close,y) then begin
sellshort(1,0,market);
buy(holding=0,1,market);
end
if holding<0 and cross(close,x) then begin
sellshort(1,0,market);
buy(holding=0,1,market);
end
if cross(x,close) then begin
sell(1,0,market);
buyshort(holding=0,1,market);
end
老师您好,下面这一段在主图显示的时候好像有问题:
if holding>0 and cross(y,close) then begin
sell(1,0,market);
buyshort(holding=0,1,market);
end
我没法贴图,只能尽量说明白:此段的原意是如果持多仓 and 收盘价下破y,则平多开空, 但是主图没有平多开空这个动作,只有一个开多,不知咋回事。另外麻烦问一下“ sell(1,0,market);”这里的0是啥意思?我如果想要控制上述动作的先后顺序,应该怎么做?
谢谢老师