samnghk 發表於 21-4-5 15:03

新手一問, 如果想連續虧損2次就暫停30分鐘

我想如果連續虧損2次就暫停30分鐘,之後再讓程式開動
不知道寫錯什麼,求高手指教,謝謝

vars: stoptrade30min (false);

if date<>date 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;
        ifclose<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
        ifclose>average(close,20) then begin
      sell next bar at market;
        end;
       
        ifclose<average(close,20) then begin
        buytocover next bar at market;
        end;
end;
end;

if positionprofit(1)>0then 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
        ifclose>average(close,20) then begin
        sell next bar at market;
        end;
       
        ifclose<average(close,20) then begin
        buytocover next bar at market;
        end;
end;
end;
end;
end;


iamernie8199 發表於 21-4-7 11:14

stoptrade30min值沒有重置
頁: [1]
查看完整版本: 新手一問, 如果想連續虧損2次就暫停30分鐘