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 fx.practic, 10-15-2013, 12:53 AM
      5 responses
      5,404 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Started by Shai Samuel, 07-02-2022, 02:46 PM
      4 responses
      95 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Started by DJ888, Yesterday, 10:57 PM
      0 responses
      7 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by MacDad, 02-25-2024, 11:48 PM
      7 responses
      159 views
      0 likes
      Last Post loganjarosz123  
      Started by Belfortbucks, Yesterday, 09:29 PM
      0 responses
      8 views
      0 likes
      Last Post Belfortbucks  
      Working...
      X