Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Submitting multiple Stop loss orders
Collapse
X
-
Submitting multiple Stop loss orders
I'm programming a bracket order manager where I'm looking to submit separate BuyStopLoss (long) and SellStopLoss (Short) orders. I have an Iorder defined for order type. However, the system is generating an error when I submit the secod stoploss order. It's clearly possible to have two working stoploss orders as I can do this of off chart trader. So how can I create two working stoploss orders?Last edited by boreland; 01-15-2010, 08:23 AM.Tags: None
-
boreland, are you working with the TraceOrders feature to debug your orders?
Most likely you run into NT's internal order handling rules with this approach -
http://www.ninjatrader-support.com/H...verview36.html (bottom section here)
-
Here is the trace output
***First I noticed this Error:
2010-01-15 12:40:16:683 ERROR: Failed to call method 'Initialize' for strategy 'FormExample': 'Position' property can not be accessed from within 'Initialize' method
Here is the code within the Initialize Method:
protected override void Initialize()
{
CalculateOnBarClose = false;
OrderNumber = 10;
textFont = new Font("Arial",11,FontStyle.Regular, GraphicsUnit.Pixel);
EntriesPerDirection = 10;
EntryHandling = EntryHandling.AllEntries;
RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction;
}
**Second here is the trace relating to the First StopLong order, which goes through to the working state, but fails on the second StopShort order:
2010-01-15 12:40:47:652 (IB) Cbi.Connection.ProcessEventArgs.OrderStatusEventAr gs: Order='793d9c8e4f26401c8a34d21547a53d87/Sim101' Name='STPLong2010-01-15 12:40:47.574' New State=Initialized Instrument='6B 03-10' Action=Buy Limit price=0 Stop price=1.6259 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
2010-01-15 12:40:47:668 (IB) Cbi.Order.Update1: oldid='793d9c8e4f26401c8a34d21547a53d87' Order='793d9c8e4f26401c8a34d21547a53d87/Sim101' Name='STPLong2010-01-15 12:40:47.574' New State=Initialized Instrument='6B 03-10' Action=Buy Limit price=0 Stop price=1.6259 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
2010-01-15 12:40:47:683 (IB) Cbi.Order.Submit: Order='793d9c8e4f26401c8a34d21547a53d87/Sim101' Name='STPLong2010-01-15 12:40:47.574' State=Initialized Instrument='6B 03-10' Action=Buy Limit price=0 Stop price=1.6259 Quantity=1 Strategy='AMKTassassin2' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='15adb90273304a849b729e9af791f7c0' Gtd='12/1/2099 12:00:00 AM'
2010-01-15 12:40:47:683 (IB) Cbi.Simulator.Submit: Order='793d9c8e4f26401c8a34d21547a53d87/Sim101' Name='STPLong2010-01-15 12:40:47.574' State=Initialized Instrument='6B 03-10' Action=Buy Limit price=0 Stop price=1.6259 Quantity=1 Strategy='AMKTassassin2' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='15adb90273304a849b729e9af791f7c0' Gtd='12/1/2099 12:00:00 AM'
2010-01-15 12:40:47:683 (IB) Cbi.Connection.ProcessEventArgs.OrderStatusEventAr gs: Order='15adb90273304a849b729e9af791f7c0/Sim101' Name='STPLong2010-01-15 12:40:47.574' New State=PendingSubmit Instrument='6B 03-10' Action=Buy Limit price=0 Stop price=1.6259 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
2010-01-15 12:40:47:683 (IB) Cbi.Order.Update1: oldid='793d9c8e4f26401c8a34d21547a53d87' Order='15adb90273304a849b729e9af791f7c0/Sim101' Name='STPLong2010-01-15 12:40:47.574' New State=PendingSubmit Instrument='6B 03-10' Action=Buy Limit price=0 Stop price=1.6259 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
2010-01-15 12:40:47:777 in OnUnhandledThreadException
2010-01-15 12:40:47:871 ********* exception trapped *********
2010-01-15 12:40:47:871 Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
2010-01-15 12:40:47:871 at System.Collections.ArrayList.get_Item(Int32 index)
at NinjaTrader.Indicator.TimeSeriesHelper.get_Item(In t32 barsAgo)
at NinjaTrader.Strategy.StrategyBase.PlaceOrder(Int32 selectedBarsInProgress, Boolean liveUntilCancelled, Action action, OrderType orderType, Int32 quantity, Double limitPrice, Double stopPrice, String signalName, String fromEntrySignal, String oco, Boolean simStop)
at NinjaTrader.Strategy.StrategyBase.EnterShortStop(I nt32 barsInProgressIndex, Boolean liveUntilCancelled, Int32 quantity, Double stopPrice, String signalName)
at NinjaTrader.Strategy.AMKTassassin2.InputAlert_Plac eBrac****rderHandler(Object sender, EventArgs e)
at NinjaMKTAssassin2.NinjaToFrom.button35_Click(Objec t sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
2010-01-15 12:40:48:011 (IB) Cbi.OrderStatusEventArgs.Process: Order='793d9c8e4f26401c8a34d21547a53d87/Sim101' Name='STPLong2010-01-15 12:40:47.574' New State=Initialized Instrument='6B 03-10' Action=Buy Limit price=0 Stop price=1.6259 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
2010-01-15 12:40:48:027 (IB) Cbi.OrderStatusEventArgs.Process: Order='15adb90273304a849b729e9af791f7c0/Sim101' Name='STPLong2010-01-15 12:40:47.574' New State=PendingSubmit Instrument='6B 03-10' Action=Buy Limit price=0 Stop price=1.6259 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
2010-01-15 12:40:48:199 (IB) Cbi.Connection.ProcessEventArgs.OrderStatusEventAr gs: Order='15adb90273304a849b729e9af791f7c0/Sim101' Name='STPLong2010-01-15 12:40:47.574' New State=Accepted Instrument='6B 03-10' Action=Buy Limit price=0 Stop price=1.6259 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
2010-01-15 12:40:48:199 (IB) Cbi.Order.Update1: oldid='15adb90273304a849b729e9af791f7c0' Order='15adb90273304a849b729e9af791f7c0/Sim101' Name='STPLong2010-01-15 12:40:47.574' New State=Accepted Instrument='6B 03-10' Action=Buy Limit price=0 Stop price=1.6259 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
2010-01-15 12:40:48:199 (IB) Cbi.OrderStatusEventArgs.Process: Order='15adb90273304a849b729e9af791f7c0/Sim101' Name='STPLong2010-01-15 12:40:47.574' New State=Accepted Instrument='6B 03-10' Action=Buy Limit price=0 Stop price=1.6259 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
Thanks
Peter
Comment
-
Are you this Initialize() refers to the correct strategy? This would be called across your strategies, so it could stem from another strategy actually.
For the stop order you would need to debug your code to only access valid (defined) index value for the trace error you posted -
2010-01-15 12:40:47:871 Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Comment
-
Bertrand
2010-01-15 12:40:16:683 ERROR: Failed to call method 'Initialize' for strategy 'FormExample': 'Position' property can not be accessed from within 'Initialize' methodAre you this Initialize() refers to the correct strategy? This would be called across your strategies, so it could stem from another strategy actually.
I'll also check to see if I'm using the 'Position" property in some other strategy.Last edited by boreland; 01-15-2010, 12:11 PM.
Comment
-
Bertrand
For the stop order you would need to debug your code to only access valid (defined) index value for the trace error you posted -
2010-01-15 12:40:47:871 Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Could you please be more specific, I'm not following you here? I'm not indexing anything (no multitimeframe, no mutli instruments). What does this Index value refer to?Last edited by boreland; 01-15-2010, 12:17 PM.
Comment
-
There is no mention of Position in the Initialize() section of the code you posted, so that is why Bertrand was asking if it was in another script. Actually, looking at the code again it is contained in the strategy called FormExample.Originally posted by boreland View PostBertrand
2010-01-15 12:40:16:683 ERROR: Failed to call method 'Initialize' for strategy 'FormExample': 'Position' property can not be accessed from within 'Initialize' method
I'll also check to see if I'm using the 'Position" property in some other strategy.
As with your other inquiry I answered, it would help us help you if you posted the code in either an email or here on the forum. Thank you.AustinNinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
558 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
324 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
545 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment