Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    BertrandNinjaTrader Customer Service

    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
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Gerik, Today, 09:40 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by RookieTrader, Today, 09:37 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by alifarahani, Today, 09:40 AM
        0 responses
        5 views
        0 likes
        Last Post alifarahani  
        Started by KennyK, 05-29-2017, 02:02 AM
        3 responses
        1,284 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by AttiM, 02-14-2024, 05:20 PM
        11 responses
        185 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X