The next day's session opens at 17:00 (exchange time), after the one hour break. I hold positions over the one hour break. I was attempting to maintain
my strategy automation over the one hour break, but my stop-loss orders are being repetitively sent to the market during the break, and therefore strategy automation is being disabled due to the numerous order rejections. I asked support about this situation and was advised that I could consider
"2) Move the logic for generating the special orders in a separate signal script. Enable IOG for this signal (Format -> Signal -> Format -> Properties):
https://www.multicharts.com/trading-sof ... Generation
Enhance this script with the logic that will monitor the current time and stop generating the orders in several minutes (or seconds) before the session end.
I am wondering if someone would be willing to help me with the logic that would monitor the current time and stop generating orders before the session end.
Preliminarily, I could copy code like below from my original strategy (for exiting a short position), but it doesn't monitor the time and prevent orders
from being generated near the close of the day session
Code: Select all
Inputs:
NBarEx1 (25), { Number of bars from entry for market exit }
NATRTrail (28), { Indicator look-back length (bars) }
ATRFrTrail (2.1301), { Multiple of price difference (e.g., ATR); exit }
TrailPct (63), { Trailing stop percentage }
MMStopPct (1.485), { Value of percentage money management stop }
MMStop(1.4878);
Var: ATRTrail (0),
SStop (0),
NewSStop (0),
StopAmnt (0),
STrailOn (false),
EndofSess (false);
{ Average true range }
ATRTrail = AvgTrueRange(NATRTrail);
{ Exit orders, short trades }
If MarketPosition = -1 then begin
If BarsSinceEntry = 0 then begin
SStop = (1 + MMStopPct/100.0) * EntryPrice;
STrailOn = false;
end;
If EntryPrice - C > ATRFrTrail * ATRTrail then
STrailOn = true;
If STrailOn then begin
NewSStop = EntryPrice - TrailPct * (EntryPrice - C)/100.0;
SStop = MinList(SStop, NewSStop);
end;
Buy to cover("ExStop-S") next bar at SStop stop;
If BarsSinceEntry >= NBarEx1 then
Buy to cover("ExMark-S") next bar at market;
end;
SetStopShare;
If MarketPosition <> 0 then
Begin
StopAmnt = MMStop;
SetStopLoss(StopAmnt);
End
else
Begin
StopAmnt = MMStop;
SetStopLoss(StopAmnt);
End;