Thanks!
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How to retrieve BarsArray[index] inside of OnExecution function?
Collapse
X
-
How to retrieve BarsArray[index] inside of OnExecution function?
Inside of the OnExecution() or OnOrderUpdate() functions, what it the best way to retrieve the BarsArray index of the instrument being traded? (This is inside of a multiple instrument strategy, and I'm trying to coordinate my entries/stops lists)
Thanks!Tags: None
-
That depends on what you mean by "best".Originally posted by kbeary33 View PostInside of the OnExecution() or OnOrderUpdate() functions, what it the best way to retrieve the BarsArray index of the instrument being traded? (This is inside of a multiple instrument strategy, and I'm trying to coordinate my entries/stops lists)
Thanks!
The easiest on the other hand, is to simply use the IOrder name. Give the IOrders names that reflect the BarsArray, then check the corresponding name of the IOrder that is the subject of the event.
-
Great, thanks very much.
I had been doing something similar:
- I have a list of IOrder entries that I use to track all of my entries, and I was manually iterating through it to see if the instruments matched:
I have my entry signals set up as:Code:protected override void OnExecution(IExecution execution) { ... foreach (KeyValuePair<int, IOrder> pair in currentOrders.longEntries) { if(pair.Value.Name == execution.Order.Name) { (...do something....) } } }
' "Entry" + BarsArray[instrumentIndex].Instrument.FullName + "-" + CurrentBar '
I would like to maintain that, since it makes it really easy to track which instruments are typically successful for each market type.
I guess what I was really asking is whether there is a way to directly expose the BarsArray index using some property of the execution. Is that possible, or is iterating through the list the only way?
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
95 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
50 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
31 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
36 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
72 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment