Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Detect a change of Market Position State

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

    Detect a change of Market Position State

    How do I detect the change of Market Position State from previous bar to the current bar?

    Do I have to use "OnPositionUpdate" ??

    Or some form of the following will work? (this does not work but gives you an idea of what I am trying to do - I am trying to check if the previous bar's Market Poisition was not Long!)

    (Position.MarketPosition[1] != MarketPosition.Long)


    Regards...

    #2
    mefTrader, unfortunately you can't access the historical MarketPosition as series - you would need to record the value to a variable or custom series for tracking and then compare.

    Comment


      #3
      Does "OnPositionUpdate" detect the change of state?

      protected override void OnPositionUpdate(IPosition position)
      {
      if (position.MarketPosition == MarketPosition.Long)
      {
      MyATRCalc = ATR(14)[0]*atr5min_trail_mult_long;
      PosLow = Low[0] - MyATRCalc ;
      }
      }

      Im trying to assess the initial condition of the stop loss here - will this work

      and then revert back to OnBarUpdate to change this Dynamically i.e change PosLow Dynamically

      Comment


        #4
        mefTrader, for this the best approach would be to reset to a default value when you're in a flat state and then updating dynamically in OnBarUpdate() later - http://www.ninjatrader.com/support/f...ead.php?t=3222

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        647 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        368 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        571 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X