Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to Determine Most Recent %d Crossover %k

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

    How to Determine Most Recent %d Crossover %k

    I am attempting to write a script to determine the following:

    1. If current bar MA(20) crosses under price
    2. Was most recent Stochastic %d crossover %k or was most recent %d crossunder %k

    I tried looking at the MRO function, but am unable to get it to work.

    Thank you,
    Jeff

    #2
    Hello,

    The MRO should do what you're looking for if you're just looking for the last time this occurred.

    Can you post what you tried working with MRO and the results you were getting that did not work? Is your strategy perhaps a mutli-series script?
    MatthewNinjaTrader Product Management

    Comment


      #3
      Thank you. I've gotten it to work, but how do I offset it.

      For example, the MA(20) crosses below the closing price on the current bar. I want to find out the previous time that the MA(20) crossed below the closing price.

      This gives me zero:
      int barsAgoMA = MRO(delegate {return CrossBelow(SMA(MA),Close,1);},1,Count);

      It is finding the current bar and returning 0. I want it to start 1 bar prior to the current bar.

      Thank you,
      Jeff

      Comment


        #4
        Jeff,

        If you're running this on CalculateOnBarClose = true, it will start 1 bar prior to the current bar. It will then wait for that bar to close to reevaluate the condition.
        MatthewNinjaTrader Product Management

        Comment


          #5
          Ok. Thank you!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          57 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          143 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          161 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          97 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          276 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X