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 helpwanted, Today, 03:06 AM
    1 response
    10 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    9 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    5 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    242 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    387 views
    1 like
    Last Post Gavini
    by Gavini
     
    Working...
    X