• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MRO() - Most Recent Occurrence

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

  • mntemel
    replied
    Hi Paul,

    Thanks for the prompt reply, so this was the message in log;

    Strategy 'test3': Error on calling 'OnBarUpdate' method on bar 1: condition Parameter name: 'MRO' on bar 1 threw exception: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
    I have increased the number of bars to start condition to 10 bars and that fixed the issue.

    Code:
    if (CurrentBars[0] < 10)
    return;
    Many thanks for your support, you guys are doing an amazing job here!
    MT

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    Hello mntemel,

    Thanks for your reply.

    I tested with tick replay enabled and there was no issue (see attached).

    Is it possible that you do not have tick data for that instrument?

    Do you see any errors in the "log" tab of the control center when the strategy is applied to a tick replay enabled chart?
    Attached Files

    Leave a comment:


  • mntemel
    replied
    Hi Paul,

    Thank you for your reply.

    I applied the strategy to a new chart and it worked. The only difference between two charts is; one has "Tick Replay" ticked, and the other not. So, when tick replay option is selected in the chart this MRO() function is not working. Is there a way around this issue?

    Thanks,
    MT

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    Hello mntemel,

    Thanks for your post.

    I copied and tested your code, it seems to work here, please see the attached example.

    Can you clarify what specifically is not working for you or what the conditions are that are not working?
    Attached Files

    Leave a comment:


  • mntemel
    started a topic MRO() - Most Recent Occurrence

    MRO() - Most Recent Occurrence

    Helloo!

    I've been trying to implement the Most Recent Occurrence function in my strategy as documented here;

    https://ninjatrader.com/support/help...urence_mro.htm

    In this simple example I'm trying to draw a line between two swing highs;

    Code:
    protected override void OnBarUpdate()
    {
    
    if (BarsInProgress != 0) 
    return;
    
    if (CurrentBars[0] < 1)
    return;
    
    int first_high_barsAgo = MRO(() => Swing(Close, 3).SwingHigh[0] != Swing(Close, 3).SwingHigh[1], 1, 99);
    int second_high_barsAgo = MRO(() => Swing(Close, 3).SwingHigh[0] != Swing(Close, 3).SwingHigh[1], 2, 99);
    
    if (first_high_barsAgo > -1 && second_high_barsAgo > -1)
    Draw.Line(this, @"v3 Line_1"+CurrentBar, false, second_high_barsAgo, High[second_high_barsAgo], first_high_barsAgo, High[first_high_barsAgo], Brushes.Plum, DashStyleHelper.Solid, 2);
    		
    }
    I can't seem to get it right, it's not working. Any idea why?

    Thanks
    MT

Latest Posts

Collapse

Topics Statistics Last Post
Started by DTSSTS, Yesterday, 10:14 PM
1 response
4 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by fredfred, Today, 04:17 PM
0 responses
10 views
0 likes
Last Post fredfred  
Started by p.lozanski, Today, 03:51 PM
0 responses
7 views
0 likes
Last Post p.lozanski  
Started by JTizz, Yesterday, 04:56 PM
1 response
25 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by brunoviveiros, Yesterday, 09:10 AM
2 responses
11 views
0 likes
Last Post NinjaTrader_ChelseaB  
Working...
X