假如CLOSE上穿MA(C,100);開倉,當(dāng)MA5下穿MA10平倉;圖表限制500根K線。
這時(shí)候,我希望當(dāng)CLOSE第一次穿越MA100的時(shí)候開倉,平倉過后,當(dāng)CLOSE再次穿越MA100的時(shí)候就不再開倉了。這個(gè)代碼怎么寫 啊
variable:n=0;
if cross(.....) and n=0 then begin
buy........;
n:=n+1;
end
if 平倉條件 and holding>0 then begin
sell......;
n:=0;
end
用全局變量來記錄上穿次數(shù)并且在第一次的時(shí)候開倉并且在平倉時(shí)重置變量