I want to make a time filter that works intrabar. For example, one minute before the bar closes, exit the open position. I want to achieve this without adding an additional data series to the chart, since that messes up the chart.
Settings
IOG on, BarMagnifier On set to one tick resolution (tick data is available), Chart: 3 minute chart (but the solution should work regardless of the chart period).
Code example
Code: Select all
[IntrabarOrderGeneration = True];
Variables:
IntraBarPersist TickCounter(0),
dtBar(0);
once cleardebug;
if (Date <> CurrentDate) then #return;
dtBar = ELDateToDateTime(Date) + ELTimeToDateTime_s(Time_s);
TickCounter += 1;
Print(FormatDate("dd-MM-yy ", dtbar), FormatTime("HH:mm:ss ", dtbar), TickCounter);
if (BarStatus(1) = 2) then
TickCounter = 0;
Code: Select all
14-02-13 12:45:00 70.00
14-02-13 12:45:00 71.00
14-02-13 12:45:00 72.00
14-02-13 12:45:00 73.00
14-02-13 12:45:00 74.00
14-02-13 12:45:00 75.00
14-02-13 12:45:00 76.00
14-02-13 12:45:00 77.00
14-02-13 12:48:00 1.00
14-02-13 12:48:00 2.00
14-02-13 12:48:00 3.00
14-02-13 12:48:00 4.00
14-02-13 12:48:00 5.00
14-02-13 12:48:00 6.00
14-02-13 12:48:00 7.00
14-02-13 12:48:00 8.00
14-02-13 12:48:00 9.00
14-02-13 12:48:00 10.00
14-02-13 12:48:00 11.00
14-02-13 12:48:00 12.00
14-02-13 12:48:00 13.00
14-02-13 12:48:00 14.00
14-02-13 12:48:00 15.00
14-02-13 12:48:00 16.00
14-02-13 12:48:00 17.00
14-02-13 12:48:00 18.00
14-02-13 12:48:00 19.00
14-02-13 12:48:00 20.00
14-02-13 12:48:00 21.00
14-02-13 12:48:00 22.00
14-02-13 12:48:00 23.00
14-02-13 12:48:00 24.00
14-02-13 12:48:00 25.00
14-02-13 12:48:00 26.00
14-02-13 12:48:00 27.00
14-02-13 12:48:00 28.00
14-02-13 12:48:00 29.00
14-02-13 12:48:00 30.00
As the output shows, while there are multiple ticks processed per bar, the time stamp of each processed tick is the bar closing time. How can I get the actual time of the tick? Anyone got an idea?