I'm developing and testing a multi-instrument automated strategy using Ninjascript. I've read the Help Guide, and made a couple of changes in my code.
My strategy is trading on real-time incoming tick data, therefore I add "CalculateOnBarClose = false;" to the Initialize() method.
Also I add the following to the very beginning of OnBarUpdate() method:
"if (Historical) return;" to make sure only real-time data will be checked.
The problem I have is that it seems all orders entered submitted in OnBarUpdate() method are submitted to the instrument referred by BarsInProgress context.
For example, my primary instrument is AAPL(BarsInProgress==0), my secondary instrument is MSFT(BarsInProgress==1).
My strategy is a real-time hedging strategy, e.g. the trading logic is based on AAPL real-time tick data, when the conditions match on AAPL most recent traded price, I'd like to LONG/SHORT MSFT using market or limit order. However I found that there is no way I can do this, since my trading logic is evaluated under the context of AAPL(BarsInProgress==0), EnterLong(), EnterLongLimit(), or even using ATM strategy will enter the order to AAPL, not MSFT!
Is there any solution to my problem?
Thanks.

Comment