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 Tburg1073, Today, 08:36 AM
        0 responses
        5 views
        0 likes
        Last Post Tburg1073  
        Started by alexstox, 10-16-2018, 03:29 PM
        10 responses
        333 views
        0 likes
        Last Post Tburg1073  
        Started by smartromain, 03-13-2024, 01:42 AM
        6 responses
        98 views
        0 likes
        Last Post smartromain  
        Started by Jonker, 04-27-2024, 01:19 PM
        4 responses
        29 views
        0 likes
        Last Post Jonker
        by Jonker
         
        Started by Yasharandom, Today, 07:45 AM
        0 responses
        5 views
        0 likes
        Last Post Yasharandom  
        Working...
        X