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

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 KonAdams, 05-07-2024, 10:53 PM
          3 responses
          18 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by ttrader23, Yesterday, 09:04 AM
          4 responses
          19 views
          0 likes
          Last Post ttrader23  
          Started by millonperez, Today, 07:01 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_ChristopherJ  
          Started by jpeep, 08-16-2020, 08:31 AM
          14 responses
          488 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by realblubb, 04-28-2024, 09:28 AM
          3 responses
          36 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X