Live Market & Replay


Hello everyone! If you have not read the first part of this article yet it might be a good idea. Nevertheless, this time we will be looking at the case of why you can get this error on live market or during market replay in NInjaTrader.


“Sell stop or sell stop limit orders can’t be placed above the market. Strategy submitted an order that generated the following error - order rejected. Strategy has sent cancel requests, attempted to close the position and terminated itself.”


To understand the situation better let us recap a little bit and remember that we are trying to change the position of the initial stop order at the moment when we hit the profit target and trail it up to break even. On the live market a hypothetical visualization of this case can look like the following.



This is the perfect scenario and probably in most cases, this would happen however there also can be some exceptions. To understand the case better let’s try and replicate what the DOME can look like for the perfect case.



In the DOME we see that when the profit target is hit if we are trading 2 lots our market price will stay between the price of 100USD and 98USD with the next available buyer located at 98USD. This makes it possible to relocate our break-even to a new level of 95USD because that is below the market and below the current bid.


However, this might not always be the case.



In the case above we see that this time when the profit target is hit the next available bid is 91 which means if we try and place a stop order at 95 we will end up above it!!! This will produce an order rejected error to appear.


On the NinjaTrader chart, this can look like this.


One of the possible protections for this scenario is to use.


GetCurrentBid()

GetCurrentAsk()


Check where the DOME is before placing any orders that can lead to the discussed situation. One of the possible workarounds is also to place the stop X bids below the profit target hit. 


Enjoy!


Please subscribe if you like the article.