Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to retrieve BarsArray[index] inside of OnExecution function?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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!

    #2
    Originally posted by kbeary33 View Post
    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!
    That depends on what you mean by "best".

    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.

    Comment


      #3
      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:

      Code:
      protected override void OnExecution(IExecution execution)
      {
      ...
          foreach (KeyValuePair<int, IOrder> pair in currentOrders.longEntries)
          {	
             if(pair.Value.Name == execution.Order.Name)
             {
                  (...do something....)
             }
          }
      }
      I have my entry signals set up as:
      ' "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 judysamnt7, 03-13-2023, 09:11 AM
      4 responses
      53 views
      0 likes
      Last Post DynamicTest  
      Started by ScottWalsh, Today, 06:52 PM
      4 responses
      33 views
      0 likes
      Last Post ScottWalsh  
      Started by olisav57, Today, 07:39 PM
      0 responses
      5 views
      0 likes
      Last Post olisav57  
      Started by trilliantrader, Today, 03:01 PM
      2 responses
      19 views
      0 likes
      Last Post helpwanted  
      Started by cre8able, Today, 07:24 PM
      0 responses
      6 views
      0 likes
      Last Post cre8able  
      Working...
      X