Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

most recent high or low

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

    most recent high or low

    since I have a multi timeframe strategy, I cannot use the built in MRO and devised my custom function. for some reason, It does not return correctly. could you look into it and share where I made a mistake?
    the intention is to return the barid of the most recent donchianchannel high crossover or low crossover
    private int mostRecentUpper()
    {
    int barid=CurrentBar-1;
    int mru=0;


    while(barid>1){
    if (High[barid] > DonchianChannel(100).Upper[barid+1])
    {
    mru=barid;
    break;
    }
    barid-=1;


    }
    return mru;

    }
    private int mostRecentLower()
    {
    int barid=CurrentBar-1;
    int mrl=0;


    while(barid>1){
    if (Low[barid] < DonchianChannel(100).Lower[barid+1])
    {
    mrl=barid;
    break;
    }
    barid-=1;


    }
    return mrl;

    }

    #2
    Hi junkone,

    There are a few terms you are using I am not familiar with.

    Can you clarify MRO (is this an indicator that you have imported?) and barid (is this a math term?).

    Your script does not appear to be a multi-time frame script. With multi-time frame I would expect to see Highs[BarsInProgressIndex][BarsAgoIndex] used along with the correct BarsArray used with the indicator call such as DonchianChannel(BarsArray[BarsInProgressIndex], 100).Upper[BarsAgoIndex].

    I see that there are two methods that return ints. When these are called, it is the value that is calculated that is incorrect, is this correct?

    Are you asking for assistance correcting your logic so that the calculation is what you are expecting?

    Have you added a secondary series and you are wanting assistance using the correct BarsInProgress indexes with Closes, Highs, Lows, Times, etc, and BarsArray index when supplying a secondary series to an indicator call?

    What does the code to add the secondary series look like?
    Are you using if conditions to ensure the code is only run during the specific BarsInProgress in OnBarUpdate?
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    672 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    379 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    111 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    575 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    582 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X