I'd like the strategies to stop attempting to update orders for a bar or two when this happens as it can crash NT8. Is there a way to do this?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Logic to make sure orders are not placed above/below market in fast markets
Collapse
X
-
Logic to make sure orders are not placed above/below market in fast markets
Good morning! I'm working on developing strategies for futures markets and when the markets are moving quickly, order updates are submitted that are above or below the market. I do have logic that filters and makes sure price is above or below before the order is submitted, but in some markets, this error still happens every day. What have others done to work around this?
I'd like the strategies to stop attempting to update orders for a bar or two when this happens as it can crash NT8. Is there a way to do this?Tags: None
-
Hello trilliantrader,
It sounds like you are already doing what you can to avoid that, if the price you are using is that close to the market that is something which will be prone to happen. The alternative would be to increase the distance your order is being placed at initially to ensure it is valid and accepted, later once it is working you can always update the order to being closer to the market. That still runs the risk of doing a change order to the wrong side of the market as well so you would still need to check that the price is valid before doing the change order.
If you have rejection handling turned off that would let the strategy keep trying to resubmit orders. In that case you would need to make sure your entry condition only becomes true one time to submit the order. You could use a variable to prevent it from trading on the same bar, for example use an Int variable and store the CurrentBar to it when you submit the order. As part of the entry condition you could check if the CurrentBar is greater than your variable meaning its been at least 1 bar since the last event.
-
Jesse,
Thank you. I am pretty green to NinjaScript and my background is more web development, so this is more helpful than you know.
Can you elaborate on the 2nd option on using the variable to see if the condition has already updated the order on the same bar? Throwing 1 error per bar is reasonable. The variable is set when the order update is run and then set back on the next bar?
Comment
-
Hello trilliantrader,
For that use case you would set the variable in your entry condition inside OnBarUpdate. For example:
Code:private int entryBar; //OnBarUpdate if(CurrentBar > entryBar && yourEntryConditions) { //entry order entryBar = CurrentBar; }
The CurrentBar always increments so there wouldn't be any need to reset the variable, it will become less than CurrentBar after 1 bar.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
50 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
126 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
69 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
42 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment