Say I have a simple rule to submit an unmanaged market-if-touched (MIT) order when price touches a moving average or some other measurement that's a moving target intra-bar because it changes as the price changes before the bar closes, and I want the order fired when price touches or crosses it.
With CalculateOnBarClose=false, this works fine in real time; the moment price crosses the moving average, the order is fired.
Getting this to work in backtesting, even with a secondary 1-tick data series, seems like it's harder than it ought to be. With a secondary data series added in the strategy, I expect OnBarUpdate() to be called multiple times on the primary series, just like in real time. But it isn't. It's especially important to have multiple OnBarUpdate() events on the primary series if I have a large number of things to set up in am if(FirstTickOfBar) block.
So here's the dumb question: Is there a switch or something available to a programmer to have OnBarUpdate() be called on the primary series every time it gets called on the secondary series? Or at least twice, once on first tick of bar and once when the bar is done?
The code to do MIT orders on live data is simple. I can't see how to do the same thing in backtest without making my code incredibly complex -- I mean, I can't exactly calculate the MIT price (like a moving average of the primary minute-bar series) on a tick series.
-Alex
Comment