I’m converting a strategy from NT7 to NT8.
The strategy being converted does not “Exit on session close” and it uses NT Managed approach with LMT orders to trade. It also calculates “OnBarClose”, Period=240 minutes, “Break at EOD = true”
I found that if a LMT order is in “working” state when the days trading session ends, that same order is still in “working” state at the opening of the next session, BUT it can’t be “Cancelled” or amended.
So, I’ve created and uploaded a simple prototype modeled after SampleMACrossOver that reproduces the error for you to see.
I’ve uploaded a screen scrape “System Analyzer with Prototype” showing how to run the prototype using System Analyzer and a text file of NT8 order TRACE
The prototype simply cancels any previous LMT order and submits a new LMT on every bar.
If you run the script with “Exit on Session Close” = true, the script runs without trade errors.
If you run the script with “Exit on Session Close” = false, the script produces errors like:
“3/3/2017 10:00:00 AM Strategy 'MyCustomStrategy99/-1': Ignored SubmitOrderManaged() method at …. Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'”
It should not produce this error since there is only 1 order per bar, any previous order is first cancelled before another order is submitted, and the order being cancelled is in “working” state.
The reason it gets this error is NT8 ignored “CancelOrder(pendingEntryOrder);” for bar “3/3/2017 10:00:00 AM”. The trace should show something like
“'MyCustomStrategy99/-1': Cancelled custom managed order:….”
like it does for all previous bars. The strategy then goes on the try an cancel the order again and again for the remaining bars of the chart, producing the same error over and over on the TRACE.
My experience has been that “CancelOrder(Order order)” is ignored by NT8 if the “order” given to the command does not exist. That makes sense.
BUT, this is not the case within the script. The order object within the script is assigned with the OnOrderUpdate event for any state but “FILLED” and set to null if it is filled.
Can you please have a look and let me know why LMT orders can’t be canceled or amended when trading “Exit on session close” = False.
Thank you
Comment