I'm having an issue with 240 minute (H4) charts and I want to develop some code that will notify me if my strategy isn't getting any data/working properly.
I know the problem is not the strategy/code because the same script works just fine on a shorter time frame (so it's also not my account connection).I managed to get the 240 minute strategy working by (a) disabling the strategy, (b) removing the strategy from the strategy window and (c) re-adding it & re-enabling the strategy. A simple disable/reenable didn't seem to cut it.
I had a look through the manual and I thought OnMarketData should do the trick. I could put some code in OnBarUpdate but then I would have to wait around for several hours to find out if the strategy is working.
Is the code below going to work? I note there are other options (like e.MarketData.Connection.Status) but the manual does not have detailed information on all the various arguments and their relevant values.
Note I put the extra condition with the boolean so that I don't get inundated with messages/alerts if there's no market data.
[INDENT]//added in variables[/INDENT][INDENT]private bool dropout = true;[/INDENT] protected override void OnMarketData (MarketDataEventArgs e) { if (e.MarketData == null && dropout == true) { //send alert //send email dropout = false; } if (e.MarketData != null) { dropout = true; } }
Comment