private Order myOrder = null; protected override void OnBarUpdate() { if (Position.Quantity < 1 && buyPatternCode1) { Order myOrder = EnterLong(sharesToBuy, "Code1"); } if (Position.Quantity < 1 && buyPatternCode2) { Order myOrder = EnterLong(sharesToBuy, "Code2"); } if (Position.Quantity >= 1 && myOrder.Name == "Code1" && sellPatternCode1) { ExitLong(); } if (Position.Quantity >= 1 && myOrder.Name == "Code2" && sellPatternCode2) { ExitLong(); } }
B) I've been doing this by writing to a file 'symbolName.code1.txt' and then looking to see if the file exists on the sell side however in backtesting this is causing for some reason inconsistent backtests. I'll run a backtest note the results then click Run again not changing anything and the new results are different than the first. So i'm trying to get away from written file usage BUT need to be able to buy say in January and sell say in February so I need to know the entry name/code used over multiple days and even NinjaTrader restarts. SO, does myOrder.Name persist across NinjaTrader restarts or is it lost?
Comment