Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Mro

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

    Mro

    Good afternoon, I am using the MRO function.

    protected override void OnBarUpdate()
    {
    // Prints the high price of the most recent up bar over the last 10 bars (current bar + look back period's 9 bars before that)
    int barsAgo = MRO(() => Close[0] > Open[0], 1, 9);
    if (barsAgo > -1)
    Print("The bar high was " + High[barsAgo]);

    In this example, instead of the last 10 bars, which the 9 represents, how can I code for Yesterdays Bar through 10 bars ago? Another words I do not want to include the current bar in the look back period.

    I tried:

    int barsAgo = MRO(() => Close[0] > Open[0], 1, (CurrentBar - 1) - 9);

    and

    int barsAgo = MRO(() => Close[0] > Open[0], 1, 1 - 9);


    this did not seem to work.

    Thanks as always for your help.

    Ryan

    #2
    Hello Tonkingrf1551,

    The MRO works based on a lookback period and not a fixed start and end point so using MRO for this purpose would not be possible. You would need to make a for loop if you wanted to do something for a specific range of bars. The loop would need to loop backward meaning it would start at an index of 10 meaning 10 bars ago from now and then you would loop counting up until you found the occurrence of what you were looking for. For example 10, 11, 12 etc until you reach the index for yesterdays bar. Based on what the loop iterator is when the condition is true would determine the found BarsAgo.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    32 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    195 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    358 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    277 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X