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 charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    68 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    150 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    100 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    288 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X