Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

plot values switch to: 0

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

    plot values switch to: 0

    Hello,

    Could some help me understand why my plot values switch to: 0 when I attempt to plot RTH OHL values on any other time frame than a 1 minute chart. When I use a 1 minute chart, the indicator plots just fine.

    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 1)
    return;

    if (CurrentBars[0] < 1)
    return;

    if (Time[0].TimeOfDay == RTHStart.TimeOfDay)
    {
    myRTHOpen = Open[0];
    myRTHHigh = High[0];
    myRTHLow = Low[0];
    }

    //if (Times[0][0].TimeOfDay >= new TimeSpan(08, 30, 00) && Times[0][0].TimeOfDay <= new TimeSpan(16,00, 00))
    if (Time[0].TimeOfDay >= RTHStart.TimeOfDay && Time[0].TimeOfDay < RTHEnd.TimeOfDay)
    {
    RTHOpen[0] = myRTHOpen;

    if (High[0] > myRTHHigh)
    {
    myRTHHigh = High[0];
    }

    if (Low[0] < myRTHLow)
    {
    myRTHLow = Low[0];
    }

    RTHHigh[0] = myRTHHigh;
    RTHLow[0] = myRTHLow;
    }
    else
    {
    RTHOpen[0] = RTHOpen[1];
    RTHHigh[0] = RTHHigh[1];
    RTHLow[0] = RTHLow[1];
    }
    Print(Time[0] + "RTHOpen[0] " + RTHOpen[0]);
    }
    Attached Files

    #2
    Hello AdeptistJune,

    Thanks for your post.

    The issue here would be to understand that Tick bars are not based on time so you may or may not have a tick precisely at a time condition such as if (Time[0].TimeOfDay == RTHStart.TimeOfDay) and this means your values may not be getting set.

    I would suggest adding a 1-minute data series so that you always have that timing reference and you may have to consider that with a faster chart data series such as 100 tick, that you could have multiple occurrences where the time match condition is true so you may need additional logic (bool variables) so that your time statement is executed only once per event, this of course means resetting the bools later for the next session.

    When creating a multi time frame indicator you will need to keep these concepts in mind: https://ninjatrader.com/support/help...nstruments.htm

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    83 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    45 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    66 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    69 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    58 views
    0 likes
    Last Post CarlTrading  
    Working...
    X