Hello waveslider,
The closing tick of the bar is determined by the opening tick of the next bar. So there is no 100% solution to send an order exactly on the closing tick of the bar, but you can get close to it. Here is what I can suggest:
Enable IOG for your signal. Start Recalculating your code two seconds before the bar close. On the next calculation or next tick (depending on the market activity) send the order you need. Example for closing a position:As an input you need to specify the time when you need to close the position, for example 152958 – is 15:29:58.Code: Select all
[intrabarordergeneration = true]
input: TimeClosePosition(0);
if (currenttime_s >= TimeClosePosition) then
Begin
RecalcLastBarAfter(1);
sell ("EOD_LX") next bar market;
buytocover("EOD_SX") next bar market;
End;
Henry,
I have a strategy that uses "Open Tomorrow" and "SetExitOnClose" When I used your above IOG code to make sure exit my trades before close, MC gave error. That with Open Tomorrow can't use IOG featured strategy.
Further more I tried to add 1 minute as data2 to issue order 1 minute before close. but again error as "Open tomorrow" can't work with "this bar close" orders as well.
Code: Select all
if t data2 = 1514 then begin sell this bar c; buytocover this bar c; end;
a) need a CONFIRM way to exit my trades before market close.
b) need a way to enter Early close days on holidays for early exit my trades.
c) Strategy is using "Open Tomorrow" order so i) Can't use "IOG" feature ii) or "This bar on close" iii) Or Data2
Please suggest.....
Awaiting