我想如果連續虧損2次就暫停30分鐘,之後再讓程式開動
不知道寫錯什麼,求高手指教,謝謝
vars: stoptrade30min (false);
if date<>date[1] then stoptrade30min=false;
if marketposition = 0 then begin
if condition4 and condition6 then begin
buy next bar at market;
end;
if condition5 and condition6 then begin
sellshort next bar at market;
end;
end;
if marketposition <> 0 then begin
if close>average(close,20) then begin
sell next bar at market;
end;
if close<average(close,20) then begin
buytocover next bar at market;
end;
end;
if positionprofit(1) <0 and positionprofit(2) <0 then begin
stoptrade30min = true ;
if stoptrade30min = true then begin
if barssinceexit(1)>=30 or totaltrades = 0 then begin
if condition4 and condition6 then begin
buy next bar at market;
end;
if condition5 and condition6 then begin
sellshort next bar at market;
end;
end;
if marketposition <> 0 then begin
if close>average(close,20) then begin
sell next bar at market;
end;
if close<average(close,20) then begin
buytocover next bar at market;
end;
end;
end;
if positionprofit(1)>0 then begin
if stoptrade30min= false then begin
if marketposition = 0 then begin
if condition4 and condition6 then begin
buy next bar at market;
end;
if condition5 and condition6 then begin
sellshort next bar at market;
end;
end;
if marketposition <> 0 then begin
if close>average(close,20) then begin
sell next bar at market;
end;
if close<average(close,20) then begin
buytocover next bar at market;
end;
end;
end;
end;
end;
|