Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
unmanaged mode / order size problems in own script changeorder
Collapse
X
-
unmanaged mode / order size problems in own script changeorder
Hi, I have my own script, so far so good. if i want to change the order size manually via charttrader, it only works downwards, upwards an additional new order is generated. in the script i query every change of the order in the OnOrderUpdate method. how can i change the existing order size instead of creating a new order?
Tags: None
-
Hello slidercom80,
Thanks for your post.
There is not enough detail provided to understand how your logic is not allowing orders to be changed in the upward direction.
To achieve your goal, I would suggest checking to see which order has changed after your order object assignment and nulling (if order has been cancelled) code in OnOrderUpdate, and then to modify the other order that you have paired with that order.
I have tested the following and I have not had trouble in my test script. I have attached it for your reference.
We look forward to assisting.Code:// Check if entry orders have been modified by user if ((shortEntry != null && longEntry != null) && (order == shortEntry || order == longEntry) && (shortEntry.OrderState == OrderState.Accepted || shortEntry.OrderState == OrderState.Working) && (longEntry.OrderState == OrderState.Accepted || longEntry.OrderState == OrderState.Working)) { if (order.Quantity != shortEntry.Quantity) ChangeOrder(shortEntry, order.Quantity, shortEntry.LimitPrice, shortEntry.StopPrice); // longEntry was changed, update shortEntry else if (order.Quantity != longEntry.Quantity) ChangeOrder(longEntry, order.Quantity, longEntry.LimitPrice, longEntry.StopPrice); // shortEntry was changed, update longEntry }Attached Files
-
Hi _Jim, thanks for the answer. i found the problem: since i don't use an oco order, the modified existing order couldn't be assigned correctly. i solved it by generating a separate oco id for the stoploss order and the takeprofit order. apparently nt needs an oco order for the assignment, the name of the order to be changed is probably not enough ;-)
because i manage all orders by myself and independent from an oco link, i only need this oco id for changing the respective order by hand.Code:if (State == State.Historical) { ocoSL = DateTime.Now.ToString() + CurrentBar + "LongExitsSL"; ocoTP1 = DateTime.Now.ToString() + CurrentBar + "LongExitsTP1"; } else { ocoSL = GetAtmStrategyUniqueId() + "LongExitsSL"; ocoTP1 = GetAtmStrategyUniqueId() + "LongExitsTP1"; }
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
116 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
61 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
40 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
44 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
82 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment