Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Access to Previous Bar MarketPosition

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

    Access to Previous Bar MarketPosition

    Hi

    I need to access the MarketPosition in previous bars directly from the OnBarUpdate() method.

    Any hint as to what is the best way to accomplish it?

    Thanks

    #2
    Hello zerosum666,

    Unfortunately MarketPosition is not available for prior bars, only its current state. You could consider building this into a 3-state data series with something like the below. You could then reference prior bars of your data series.

    Please see here for help working with custom data series.

    Code:
    if(Position.MarketPosition == MarketPosition.Flat)
    myDataSeries.Set(0);
    
    else if (Position.MarketPosition == MarketPosition.Long)
    myDataSeries.Set(1);
    
    else if (Position.MarketPosition == MarketPosition.Short)
    myDataSeries.Set(-1);
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    102 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    144 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    71 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    125 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    79 views
    0 likes
    Last Post PaulMohn  
    Working...
    X