Thanks.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Limit Orders to Sell
Collapse
X
-
Limit Orders to Sell
When stops and targets are sent by a strategy I see stop orders being rejected if market has crossed that price already. In case of a sell limit target order will NT8 still place it as market is trading at a better price than the specified limit price? This happens in fast markets in a scalping environment.
Thanks.Tags: None
-
Hello Trader17,
Thanks for your post.
This error message means that the strategy attempted to place an order to the wrong side of the market. Buy stop orders must be placed above the current ask price. Sell stop orders must be placed below the current bid price.
If this is due to market volatility then there isn't really a way to 100% avoid this occurring, as in volatile markets the market could move so far and fast that this would occur.
When the order is submitted, is the stop price parameter greater than the GetCurrentAsk() for a buy stop order? Or, is the stop price parameter less than the GetCurrentBid() for a sell stop order?
You would need to add prints to the strategy to determine why the stop order is being ignored. One line above where the stop order is placed, print the GetCurrentAsk()/GetCurrentBid() and print the price being submitted to the order method.
Something you could consider is using GetCurrentBid() and GetCurrentAsk() to offset orders so that they are more likely to land on the correct side of the market.
See these help guide pages for more information.
GetCurrentBid(): https://ninjatrader.com/support/help...currentbid.htm
GetCurrentAsk(): https://ninjatrader.com/support/help...currentask.htm
Below is a link to a forum post that demonstrates using prints to understand behavior.
https://ninjatrader.com/support/foru...121#post791121
You could also consider using RealtimeErrorHandling.IgnoreAllErrors to trap order errors in OnOrderUpdate.
Please note that setting this property value to IgnoreAllErrors can have serious adverse affects on a running strategy unless you have programmed your own order rejection handling in the OnOrderUpdate() method. To do this you could trap the rejected order by checking if the OrderState is Rejected within OnOrderUpdate() followed by defining your own order rejection handling behavior for the rejected order.
Please see the example in the help guide link below that demonstrates using RealtimeErrorHandling and trapping a rejected order in OnOrderUpdate().
RealtimeErrorHandling — https://ninjatrader.com/es/support/h...orhandling.htm<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
-
Originally posted by NinjaTrader_BrandonH View PostHello Trader17,
Thanks for your post.
This error message means that the strategy attempted to place an order to the wrong side of the market. Buy stop orders must be placed above the current ask price. Sell stop orders must be placed below the current bid price.
If this is due to market volatility then there isn't really a way to 100% avoid this occurring, as in volatile markets the market could move so far and fast that this would occur.
When the order is submitted, is the stop price parameter greater than the GetCurrentAsk() for a buy stop order? Or, is the stop price parameter less than the GetCurrentBid() for a sell stop order?
You would need to add prints to the strategy to determine why the stop order is being ignored. One line above where the stop order is placed, print the GetCurrentAsk()/GetCurrentBid() and print the price being submitted to the order method.
Something you could consider is using GetCurrentBid() and GetCurrentAsk() to offset orders so that they are more likely to land on the correct side of the market.
See these help guide pages for more information.
GetCurrentBid(): https://ninjatrader.com/support/help...currentbid.htm
GetCurrentAsk(): https://ninjatrader.com/support/help...currentask.htm
Below is a link to a forum post that demonstrates using prints to understand behavior.
https://ninjatrader.com/support/foru...121#post791121
You could also consider using RealtimeErrorHandling.IgnoreAllErrors to trap order errors in OnOrderUpdate.
Please note that setting this property value to IgnoreAllErrors can have serious adverse affects on a running strategy unless you have programmed your own order rejection handling in the OnOrderUpdate() method. To do this you could trap the rejected order by checking if the OrderState is Rejected within OnOrderUpdate() followed by defining your own order rejection handling behavior for the rejected order.
Please see the example in the help guide link below that demonstrates using RealtimeErrorHandling and trapping a rejected order in OnOrderUpdate().
RealtimeErrorHandling — https://ninjatrader.com/es/support/h...orhandling.htm
Thanks NinjaTrader_BrandonH for the detailed explanation. The Stop Orders I understood that market has run away from stop price. But my specific query was that after entering a position in case of a volatile market say your target has already been reached, will NT8 still send that sell limit order as it is better than the limit price?
Thanks.
Comment
-
Hello Trader17,
Thanks for your notes.
Profit target orders are placed a certain distance away from the average entry price.
If you are submitting the profit target order, such as by using ExitLongLimit(), and the market price moves higher than the limit price of the profit target order then it could be possible that the order is filled at a market order.
However, it is also possible that the order would be rejected since it was not placed on the correct side of the market depending on how fast the market is moving.
That said, you should make sure that profit target orders are being submitted to the correct side of the market to prevent any order rejections from occurring
<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
- Likes 1
Comment
-
Thanks NinjaTrader_BrandonH for the reply. Wish NT8 would not throw off error messages and liquidate sometimes when the order is in your favor.Originally posted by NinjaTrader_BrandonH View PostHello Trader17,
Thanks for your notes.
Profit target orders are placed a certain distance away from the average entry price.
If you are submitting the profit target order, such as by using ExitLongLimit(), and the market price moves higher than the limit price of the profit target order then it could be possible that the order is filled at a market order.
However, it is also possible that the order would be rejected since it was not placed on the correct side of the market depending on how fast the market is moving.
That said, you should make sure that profit target orders are being submitted to the correct side of the market to prevent any order rejections from occurring
So do orders like ExitLongLimit() calculate on each price change in a strategy even if rest of conditions are calculated once per bar?
Thanks.
Comment
-
Hello Trader17,
Thanks for your notes.
All orders would process at the close of a bar if the strategy is set to Calculate.OnBarClose.
Logic can be separated between Calculate.OnEachTick and Calculate.OnBarClose using IsFirstTickOfBar. Please note that a hosted script will inherit the Calculate mode of the script that hosts it. You can take the following approach to differentiate logic between OnBarClose and OnEachTick processing.
Please see this reference sample which demonstrates a technique used for those who need to separate their logic to calculate some values on each tick and others only on the close of a bar. You will set your host script to Calculate.OnEachTick and use if(IsFirstTickOfBar) and place all code that needs to calculate once every bar within that condition check. Then place all code that you want to calculate OnEachTick outside of the IsFirstTickOfBar condition check.
SampleEnterOnceExitEveryTick -https://ninjatrader.com/support/help...either_cal.htm<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
88 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
48 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
30 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
34 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
68 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment