Hi Dom993, I am having an issue with ninja strategy. When I loose connection, how do I retrieve orders that I currently have in the market? I use order object not being null for various reasons including closing the positions. Once I loose connection, my order object is null after reconnect. Any help is greatly appreciated. Thanks, redduke
As long as the current strategy instance is running, there is no reason for an IOrder to "disappear" (you wrote my order object is null after reconnect). If your strategy instance is terminated, and a new instance is started, then the new instance *cannot* access orders placed by the old instance. Of course when it starts, all of its IOrder variables are null. Can't really help you much more from your post - from here, I suggest contacting the NinjaTrader support forum - or contact me via email if you want to discuss your situation further with me.
Dom993, Thanks for this info. How do you handle the weekends then when a strategy runs for few weeks? I currently used TWS from IB and not sure how to handle the weekends. Thanks
The high-level idea: In OnTermination(), my strategies take note (in a file) of their current position & open-orders, then cancel all open-orders. When restarted, the strategies restore their current position (I do that using a MKT order while in Historical, and I make sure I don't issue any other order while in Historical), then on the 1st non-Historical bar I restore the prior open-orders. Note: To do this, you must use "Immediately submit live working historical orders" In Options / Strategies / NinjaScript. Having no open-orders while the strategy is stopped "guarantees" the existing position will be identical when the strategy is restarted. This way, I can stop & restart my strategies any-time.
Hi Dom993, Thanks a lot for this info. Makes perfect sense. Do you know if I can create DB tables within Ninja and use them instead of files? Regards, redduke
You really like living dangerously, don't you? Leave NinjaTrader DB alone, use your own files or your own DB if you think you need a DB. Cheers Dominique
DOM933 - This thread seem a year old, but I have this situation that refer to only problem i have using "Immediately submit live working historical orders" is when I start a chart for 1st time, it some times places orders in opposite direction of Trend in my chart. if my chart has SHORT trend, it places LONG I understand it places from live working historical orders, but how do I correct placing order in correct trend/direction of my chart thks and appreciate the help
I had a coder who wrote strategy for me. But I chose "Immediately submit live working historical orders" from NT --> options --> strategies Tab --> Ninjascript