I have a question about the OnMarketData method Note 7. It states that The OnMarketData() method is guaranteed to always be called after OnBarUpdate(). This creates a data timing problem when data from the last OnMarketData is needed for calculations in OnBarUpdate when the bar closes.
e.g. Calculate = On bar close. Data is being collected in OnMarketData for calculations to be done in OnBarUpdate. When the bar closes OnBarUpdate executes first but data from OnMarketData, that belongs to that bar, is needed first. Otherwise, the data from OnMarketData will be placed/used in the next bar, not the bar it belongs to.
When running on a tick chart, the very last tick that closes the bar, it's OnMarketData event occurs after OnBarUpdate, so OnBarUpdate executes and the bar is closed. Then, OnMarketData executes and the last tick’s data is not available to the bar that just closed.
Is this understanding correct? Or, is there more to Note 7 that needs clarification?
Thanks.
PS The forum logged me out before I finished typing my question. You should really increase the log-out time setting.
Comment