Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MRO logic question

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

    MRO logic question

    Greetings,

    I've got this line of code in a strategy, it seems to work fine:

    LO_CONSTRAINT = MRO(delegate {return VarStoch(3, 5, 3, 3).VarStoK[0] >= 97;}, 1, NEW_RISE);

    The next line uses this value in the following command:

    HI_CONSTRAINT = MRO(delegate {return VarStoch(3, 5, 3, 3).VarStoK[0] < 97;}, 1, NEW_RISE - (LO_CONSTRAINT + 1));

    This returns a value of "0", which it should not. I simply want to "go back" to the "LO_CONSTRAINT" value (+1 bar) FROM the "NEW_RISE" value and calculate the last time the VarStoK value was < 97...where is the logic error here?

    Thus for example if "NEW_RISE" is bar #500 and "LO_CONSTRAINT" is 15 bars before that (#485) I want to get the "HI_CONSTRAINT" value to be the last true conditional measured back from bar #484...hope that makes sense...thanks in advance for any advice.

    #2
    Hi Burga1,

    I feel you may be misinterpreting how the lookBackPeriod parameter is used. Whatever value you pass in is in relation to where you currently are on the chart. You will always start MRO at CurrentBar (the last bar of the chart). You pass in lookBackPeriod as a value that it will look back in relation to CurrentBar and NOT as an absolute bar you want it to look back to.

    For instance, the last bar of the chart is bar # current bar. This bar can also be seen as 0 from a backward view. The lookBackPeriod will be 10. This implies 10 bars look through the 10 previous bars from the last bar. The absolute bar number it will lookback to is CurrentBar - 10, but you would pass in 10 as the lookBackPeriod.

    Hope that helps.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      OK, thank you. I think I am misinterpreting. What if I wanted to look for an MRO within a certain time frame? For example if I check for a conditional FROM 20 bars back to 10 bars back? Thus only for those 10 bars that are now in a "past" timeframe (compared to CurrentBar)...Possible?

      Comment


        #4
        I would suggest creating your own loop to do that in your situation then. A for loop or a while loop should do the trick rather than hacking about trying to force MRO to work in the context you want.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          OK, sounds good...I'll give it a try.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          648 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          574 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X