In my strategy, I want to close all trades after 3 pm. The code works fine in 99% of all cases.
I added a time series = 1 min in the Initialize() method and I use a time comparison OnBarUpdate() method.
protected override void OnBarUpdate()
{
[code]
if(BarsInProgress == 8)
{
Print(Time[0].ToString("dd-MMM HH:mm:ss"));
if(ToTime(Time[0]) >= IniHour*10000+IniMin*100)
{
[code to close trades]
}
}
}
However, when there is no data (I guess that's the reason), the time is not printed in the output window and the trade is not closed.
I am attaching two images:
- one showing the gap in the price
- the other is the output windows where there is a gap also in the time being printed (e.g. 29 nov 12:15 to 01 dec 17:01)
Is there a workaround that does not depend on the OnBarUpdate() method to close all trades after an specific time?
Thanks,
Comment