Using Ninjatrader version 8.0.27.1 64-bit
I created a strategy to issue and manage orders using the AtmStrategyCreate() command.
Once a new entry order is created, i wait for the order to get filled to move the stop order to a certain distance away from the position average price.
It works fine but once in a while i get an error when using this command before updating the stop loss:
GetAtmStrategyStopTargetOrderStatus(string orderName, string atmStrategyId)
The error message i get is this:
'GetAtmStrategyStopTargetOrderStatus' method error: Order name 'Stop1' is invalid
I have not been able to catch this error with Ninjascript.
My script deals with it without affecting the behavior of my strategy but the error is logged into the Log window which i would like to avoid.
I know this error has been described in other threads and i have implemented the solutions proposed.
I also know it occurs because the Stop order has not been created or submitted yet but what i find strange is that my script
make sure the entry order has been Filled and the position average price is greater than 0 which it should be since the entry order
has been Filled. Finally, i make sure the the position is not Flat before checking the status of the Stop order associated to the entry order.
Despite all these checks, the error still pops up occasionaly during a trading session.
Can you see anything wrong with the part of my script which modify the stop loss ?
Here is what i get in the message window when an error occurs:
Note that despite the fact the error is raised, the script do its job and wait for the next OnBarUpdate
which happens a couple of times before the order gets accepted.
Anyway, i'd like to prevent this error from showing in the Log window.
---
'GetAtmStrategyStopTargetOrderStatus' method error: Order name 'Stop1' is invalid
needs to wait some more. Stop/target has not been created (or submitted) yet
needs to wait some more before order gets accepted
needs to wait some more before order gets accepted
needs to wait some more before order gets accepted
needs to wait some more before order gets accepted
needs to wait some more before order gets accepted
needs to wait some more before order gets accepted
needs to wait some more before order gets accepted
needs to wait some more before order gets accepted
needs to wait some more before order gets accepted
needs to wait some more before order gets accepted
needs to wait some more before order gets accepted
needs to wait some more before order gets accepted
needs to wait some more before order gets accepted
needs to wait some more before order gets accepted
needs to wait some more before order gets accepted
needs to wait some more before order gets accepted
needs to wait some more before order gets accepted
Stop order Accepted
---
Comment