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 CaptainJack, 05-29-2026, 05:09 AM
        0 responses
        244 views
        0 likes
        Last Post CaptainJack  
        Started by CaptainJack, 05-29-2026, 12:02 AM
        0 responses
        157 views
        0 likes
        Last Post CaptainJack  
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        165 views
        1 like
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        249 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        200 views
        0 likes
        Last Post CarlTrading  
        Working...
        X