This isn't so much about MC but more of a coding issue which I was hoping to seek some help here. My strategy enters a stop order just before the close but I would like to cancel the stop order if it is not filled before the close and prevent it from being executed in the after hours.
1. In this specific case, my chart settings for Eurex symbols set the session end at 1730 exchange time.
2. I enter a stop order at 1715 just before the close (e.g 1 bar interval of 15 mins).
3. My chart stops displaying data after 1730 but the order is still held at the broker end (IB) until 2200hrs (post hours continue immediately after 1730 until 2200).
I would have thought with the code below it would cancel orders at the session close but it still remains held possibly due that my chart has already stopped. I was wondering if you guys have any suggestions to a quick workaround as to what I could do to cancel the orders without altering the chart settings. Thanks!
Code: Select all
var: EntryPeriod(0);
EntryPeriod = CalcTime(SessionEndTime(0,1), -1 * BarInterval); {Enters order before close}
{Order Entry}
If Time = EntryPeriod and Time <= SessionEndTime(0,1) {Enters order before close but does not remove order after hours}
then SellShort next bar at OpenD(0) + 1 point Stop;
{Error Check}
if LastBarOnChart then begin
ClearPrintLog;
print(
"Entry Period"," ",EntryPeriod,newline,
"Session Close"," ",SessionEndTime(0,1),newline,
"");
End;