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
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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.
JesseNinjaTrader Customer Service
-
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.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by wuannetraam, Yesterday, 07:43 AM
|
2 responses
24 views
0 likes
|
Last Post
by wuannetraam
Today, 03:57 AM
|
||
Started by hsammons87, Yesterday, 05:21 PM
|
1 response
16 views
0 likes
|
Last Post
by peter629
Today, 03:51 AM
|
||
Started by thegeniuswavebyt, Today, 03:40 AM
|
0 responses
8 views
0 likes
|
Last Post Today, 03:40 AM | ||
Started by David Hill, Today, 02:57 AM
|
0 responses
21 views
0 likes
|
Last Post
by David Hill
Today, 02:57 AM
|
||
Started by r68cervera, 05-15-2024, 02:54 AM
|
6 responses
36 views
0 likes
|
Last Post
by r68cervera
Today, 02:54 AM
|
Comment