I've been having an issue where I am unable to utilize a strategy I've developed because my chart freezes - this specifically happens after my strategy has taken profit and is attempting to adjust the stop loss with each increase in profit (per tick.) The strategy is running OnTickUpdate.
I originally sent this in as a support request ticket but they're not receiving my replies for some reason, so I'd like to continue the conversation here.
After my initial support request, I received the following response:
2024-04-11 11:42:23:716 ERROR: Received position for unkown symbol 'CMENQM4', account 'S1Mar193771623'
The error is due to an improper instrument update received from a Rithmic based connection.
Initially I was receiving an error message whenever the chart would freeze ("Received position for unkown symbol 'CMENQM4', account 'S1Mar193771623"), but after the update the error message no longer appeared. However, the freezing continued in the exact same spot.
"After the update, the error messages did not appear but the chart did freeze at the same place where the error messages would've occurred - when my trade hits its profit target and the strategy attempts to adjust the stop accordingly. I can see that the chart is still loaded because my PnL statement will change with the price movement, but the chart itself is frozen. If I attempt to manually close the trade when this happens, the entire program freezes and becomes unresponsive. If I force-close NT when this issue occurs and restart the program altogether, my trade will re-appear as still active and at that point I am able to close the trade manually without freezing. Restarting the strategy, then letting it take another entry will result in the same issue occurring again."
So to confirm, the issue is as follows:
1) Enable strategy, which enters a trade when specific conditions are met
2) Strategy hits breakeven and moves the stop loss once (SetStopLoss), no issue
3) Strategy hits profit target and starts adjusting the stop with the price movement (SetStopLoss)
4) Chart freezes - strategy stays enabled and the PnL marker for my trade continues to change despite the chart itself being stuck.
5) Attempting to close the trade manually, or disable the strategy, will result in NinjaTrader freezing altogether.
6) Restarting NT resolves the frozen chart and allows me to close the trade manually, but the strategy is disabled at this point so I am unable to keep using it.
This happens on both my Sim101 account and my TopStep live accounts, utilizing the Rithmic R|Trader Pro data connection.
The script / my strategy is being run OnEachTick as it needs to adjust the stop loss with no latency. Tick Replay is not enabled. This problem only appears in the live environment; running at Max Speed on Playback works perfectly with no lag or latency issues. AddDataSeries() is not called at all. The stop loss updates are being called as part of OnBarUpdate. Here is the relevant code: https://pastebin.com/3vC951TV
Comment