tu Max
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How to modify an order from a strategy?
Collapse
X
-
I have this double entry problem where my strategy cancels the OLD limit order and
sends in a NEW one at the opening of the next bar.
I've able to produce this same bug few times.
What happened was the OLD limit order did NOT cancel on time when the NEW limit order was issue. If the price touch the OLD + NEW limit order prices quickly (fast market), it will result in BOTH the OLD + NEW limit order being filled.
Can I modify my existing LIMIT ORDER to prevent this from happening?
Thanks!
>Jim
Comment
-
Jim,
As you call EnterLongLimit() again it should just modify any preexisting order. If your existing order was filled in that very instant that the order was making it across the internet to your brokerage then the scenario you are seeing is very possible.
What you want to do in these instances is to address the extra order and immediately cancel that when you notice such a case. To cancel an order you can use CancelOrder(). Also, prevention is key here too. Try using if (Position.MarketPosition == MarketPosition.Flat) to ensure you are flat at the time of order submission. This will not weed out all race conditions, but will help keep it rare.Josh P.NinjaTrader Customer Service
Comment
-
To Modify a Limit order
Hi Josh,Originally posted by NinjaTrader_Josh View PostTo modify your order just call EnterLongStopLimit() or whichever method you were using again with your new parameters.
In my strategy, I have limit order and stop/profit target orders tied to it. see code:
entryLongOrder = EnterLongLimit(0, true, 1, entryPrice, "LongEntry");
SetStopLoss("LongEntry", CalculationMode.Ticks, stopOffset, false);
SetProfitTarget("LongEntry", CalculationMode.Ticks, profTargetOffset);
My question is, if I want to modify the limit price by recall EnterLongLimit(...) with a new entry price, do I need to do anything with the StopLoss and ProfTarget orders? (My guess is not, since I use the offset mode for these orders, unless I want change these offsets, Am I right?)
Regards,
JD
Comment
-
Nice thread.
I was wondering, is it possible (in a strategy) to change the entry and exit prices? For example, if I wanted to measure the efficiency of an trading strategy, I would like to compare it to the results of buying at the bottom and selling at the top. That way I can measure how much of the total move gets captured by the strategy, which in turn gives an indication of quality of the strategy.
But to arrive at the data of the total move (and all the moves in the time window), I need to code something as "if the move is over, the enter long price was the MIN(Low) value and the exit long was the MAX(high) value". Can I change the entry and exit prices afterwards? Perhaps there is a different way?
Can anyone give me some pointers for the creation of such a (non-tradeable) strategy?
Regards,
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
572 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
331 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
549 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
550 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment