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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        152 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        89 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        131 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        127 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        107 views
        0 likes
        Last Post CarlTrading  
        Working...
        X