One of my stop out signal keeps sending orders after the market is close, which makes the automated order execution be turned off after 100 times of rejection.
I am sure I set the session time correctly, I even set a 30 seconds buffer before closing time trying to avoid it(as code below).
It seems that this occurs randomly, because it happened on Silver(SI) and Platinum(PL) yesterday, but not on Gold(GC) or WTI(CL).
Where SI and GC are both on COMEX, PL and CL are both on NYMEX.
Any solution?
Thanks.
Code: Select all
[IntrabarOrderGeneration = true];
inputs: StopLossPct( .02 ) ;
vars: EndTime(0), StartTime(0), IsClose(True);
StartTime = SessionStartTime(1,dayofweek(date));
EndTime = SessionEndTime(1,dayofweek(date));
IsClose = IFFLogic(EndTime <= StartTime,
(TimeToSeconds(currenttime_s) + 30 > TimeToSeconds(EndTime *100) and TimeToSeconds(currenttime_s) < TimeToSeconds(StartTime * 100)),
(TimeToSeconds(currenttime_s) + 30 > TimeToSeconds(EndTime *100) or TimeToSeconds(currenttime_s) < TimeToSeconds(StartTime *100)));
setstopcontract ;
if not IsClose then begin
SetStopLoss( EntryPrice * StopLossPct * BigPointValue )
end;
https://imgur.com/a/jgy9cax