I have a strategy which is doing some position checkup/management periodically. Basically, it is designed to be executed each time it receives new data from server, something like:
protected override void OnBarUpdate()
{
if (Historical)
{
return;
}
Print("Executing at: " + DateTime.Now);
//...
doStuff();
//...
}
Now, in principle, it is working fine for most of the time, however it appears to be some periods when it is not working properly since it is not receiving data anymore (so basically, not even the "Executing at: " gets printed).
It's hard to exactly define these periods, appearantly each day a few hours before 00:00 GMT (possibly some platform unavailability time for maintenance activities? although it seems I can still submit orders etc. during these times).
So currently I'm trying to figure out a workaround for this, and I am thinking of the following options:
1. reconfigure the data connection? I noticed that if I use for instance the simulated data feed I still receive data even during these hours, so I was thinking to use it as a backup connection (but I haven't tested yet, don't even know if it might make sense);
2. implement a workaround as to have some piece of code running periodically and calling my business logic (the "doStuff" method). However I am not sure of the best way to achieve this, since:
- I think working with Thread.Sleep would not be advisable, if I understand correctly it would interfere with built-in event processing in Ninja Trader;
- maybe using a Timer instead would be a better idea? (as it is described for instance here: https://ninjatrader.com/support/foru...-general-timer)
What would you think it would be more appropriate from the above options? Any other ideas are welcome.
Thanks,
Sorin
Comment