Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using MRO as lookback for previous conditions gives errors ?

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

    Using MRO as lookback for previous conditions gives errors ?

    Getting error below when trying to use MRO for referencing a condition :
    The best overloaded method match for 'NinjaTrader.NinjaScript.NinjaScriptBase.MRO(Syste m.Func<bool>, int, int)' has some invalid arguments
    Argument 1: cannot convert from 'bool' to 'System.Func<bool>'
    DvgBullTrigger = (MRO(RSIPosDvg,1,20) && CrossAbove(EMA(8),EMA(21),1) && Volume[0] > volumeSma[0]);

    Trying to add divergence breakout plots to the open source VPA new version, tried using MRO as in User Guide and this way with no success , any pointers/fixes greatly appreciated.

    #2
    Hello Tradarr,

    The error is stating that you did not form the MRO condition correctly. Its expecting a function and not just a true/false bool. The MRO is also not returning a bool so you can't use it like you have shown. MRO returns an integer which represents the number of BarsAgo.

    You would need to form it just like the help guide sample:

    Code:
     int barsAgo = MRO([COLOR=#27ae60][B]() =>[/B][/COLOR] [COLOR=#c0392b]Close[0] > Open[0][/COLOR], 1, 9);
    The () => is what defines a function and the Close greater than Open is what the function is checking.

    If RSIPosDvg is a bool you would need to also calculate that value within the MRO function and not before the function.

    Code:
    int barsAgo = MRO(() =>
    {
        bool RSIPosDvg = false;
       // calculate RSIPosDvg
       return RSIPosDvg;
    }, 1, 9);
    The overall condition you have shown could not use the MRO as part of the condition as is, its a BarsAgo so now that you have the BarsAgo you could use that to retrieve data or use it in some way. The CrossAbove condition and volume condition would need to be seperate or you would need to figure out how you wanted to use the MRO bars ago in that condition.

    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    628 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    359 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    562 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X