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

Slope() as part of condition for MRO()

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

    Slope() as part of condition for MRO()

    Hello,

    Is it possible to use the Slope() method as part of the true/false condition to be tested within the MRO() method? I have tried the following code but I do not seem to be getting the results:

    int endBarsAgo = 1;
    int barsAgo = MRO(delegate{return hPrice[2] <= hPrice[1] && hPrice[1] > hPrice[0] && Slope(hIndic, 1, endBarsAgo) < slopeRef;}, idx, CurrentBar - 2) + 1;

    Can anyone help?

    Thanks,

    Stopped

    #2
    Stopped, I have personally never played with this combo, but would believe it should work, as a MRO simply requires a true / false condition. So if you're getting the desired results, I would suggest debugging the condtion first outside of MRO to ensure it hit's as you expect.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,

      Thanks for your quick reply. Yes, the condition hits as I expect, but in order to test it outside the MRO() method, I need to substitute the startBarsAgo input in the following manner - notice the substitution of 1 for barsAgo in Slope():

      int barsAgo = MRO(delegate{return hPrice[2] <= hPrice[1] && hPrice[1] > hPrice[0];}, idx, CurrentBar - 2) + 1;
      bool slopeCond = Slope(hIndic, barsAgo, endBarsAgo) < slopeRef;

      What I do not seem to get MRO doing is to read the Slope() method when used inside the condition.

      Any help there? Can you see if I am doing something wrong?

      Generally, are there any advantages in terms of PC performance when using overcomplicated conditions in the MRO method that would reduce the number of passes in a for-loop instead of breaking them up into smaller coding bits even if that increases the necessary loops in order to get a final result?

      Thanks again,

      Stopped

      Comment


        #4
        Stopped, Slope would return you only a double value and accessing any historical value would only be possible if you first store it's value in a dataseries - could that be throwing off your use of Slope in the MRO condition?

        It's hard to generalize how code would perform in various combinations encountered, if you're concerned about calculation speed employ times to measure the execution times seen - I like to split things apart to improve layout and readability (especially if you revisit code after some time).
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by fitspressoburnfat, Today, 04:25 AM
        0 responses
        2 views
        0 likes
        Last Post fitspressoburnfat  
        Started by Skifree, Today, 03:41 AM
        1 response
        4 views
        0 likes
        Last Post Skifree
        by Skifree
         
        Started by usazencort, Today, 01:16 AM
        0 responses
        1 view
        0 likes
        Last Post usazencort  
        Started by kaywai, 09-01-2023, 08:44 PM
        5 responses
        603 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by xiinteractive, 04-09-2024, 08:08 AM
        6 responses
        23 views
        0 likes
        Last Post xiinteractive  
        Working...
        X