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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        153 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        89 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        133 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        128 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        107 views
        0 likes
        Last Post CarlTrading  
        Working...
        X