Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get Position Average Price on another instrument

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

    Get Position Average Price on another instrument

    Hello NT Team,

    is there a way to get an instrument Average Price on a chart of another instrument ?

    for example Im running my strategy on "ES" chart and I want to get Position.AveragePrice of "MES" I know that exist a way to call this using a
    Code:
    GetInstrument
    methode or something, but Im not able to find it now.

    Thank you

    #2
    Hello MohammedAmine,

    Thanks for your post.

    The GetInstrument() method would not meet your needs as it only returns the instrument object which can provide basic information about the instrument itself and not position or account data. Reference: https://ninjatrader.com/support/help...instrument.htm

    To find the position and price of another instrument you would need to add the Account Class to your strategy along with your own private OnPositionUpdate().

    I've attached an example that you can use to test with. It is set up to provide position information on any other instrument that changed positions. It also will look for an update when 'ES 03-22" changes position. To test, apply to an instrument that is not ES 03-22 and then place manual orders on ES 03-22.

    Note: Open the New>Ninjascript output window to see the expected output when position changes.

    AccountStuff.zip
    Attached Files
    Last edited by NinjaTrader_PaulH; 12-28-2021, 07:37 AM. Reason: Added information about opening New>Ninjascript output window.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    88 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    134 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    69 views
    0 likes
    Last Post PaulMohn  
    Working...
    X