Announcement

Collapse
No announcement yet.

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.

    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).

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        646 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        367 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        107 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        569 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X