Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time[0] and Time[1] not lining up with High[0]

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

    Time[0] and Time[1] not lining up with High[0]

    I am having trouble with things lining up correctly. I have adding a data servies of 1 day bars. The chart is 60 minute chart.

    As can see in my code, I using barsproress of 1, which is the 1 day bars series.

    I am calculating the pivot for yesterday for hpivot. I then calculate the next day after to draw the pivot. This works fine thus far.

    I then have a high, low, close, open, Time[1] and Time[0] lines being drawn on the chart. Screenshot of the lines attached.

    The red vertical line is Time[1]. Blue vertical is Time[0]. Since these are day bars, when I use Open[0], then it should be opening close to the red line. But as you can see the purpose line (Open[0]) is the open of 4 bars after the red line.

    I am using the Forex template, which is setup using its defaults.

    I have included the code below that made the attached screenshot.

    What am I doing wrong that the Open, High, Low, Close is not falling within Time[1] and Time[0]?

    By the way, I trying to port the code from NT7 to NT8. So in NT7 it works just fine with no problems. After I ported it to NT8, now it is not working as designed. I add this in case it helps with diagnosis.

    Thanks
    Stearno

    Code:
    	if (BarsInProgress == 1)
    			{  
    				hpivot 			= 	(High[1]+Low[1]+Close[1])/3;
    				PivotBegin		=	Time[1];
    				PivotEnd		=	Time[0];
    				CurrentDayBegin	=	(CurrentBar - Bars.GetBar(Time[0]))+1;
    				CurrentDayEnd	=	CurrentDayBegin - barsinaperiod+1;
    				
    //Print(hpivot +" "+ CurrentDayBegin +" "+ CurrentDayEnd +" "+ PivotBegin +" "+ PivotEnd);
    Print(CurrentDayBegin +" "+ CurrentDayEnd +" "+ PivotBegin +" "+ PivotEnd);
    //Draw.Line(this, "MissedPivotAlways"+k, false, CurrentDayBegin, hpivot, CurrentDayEnd, hpivot, Brushes.Orange , DashStyleHelper.Dash,1);
    //Draw.Line(this, "Close"+k, false, PivotBegin, Close[0], PivotEnd,  Close[0], Brushes.Blue , DashStyleHelper.Solid,1);
    //				k++;
    				
    				if(hpivot > High[0] || hpivot < Low[0])
    					{
    Draw.Line(this, "Low"+k, false, PivotBegin, Low[0], PivotEnd, Low[0], Brushes.Yellow , DashStyleHelper.Solid,1);
    Draw.Line(this, "Open"+k, false, PivotBegin, Open[0], PivotEnd, Open[0], Brushes.Purple , DashStyleHelper.Solid,1);
    Draw.Line(this, "High"+k, false, PivotBegin, High[0], PivotEnd, High[0], Brushes.Red , DashStyleHelper.Solid,1);
    Draw.VerticalLine(this, "CurrentDayend"+k, Time[0], Brushes.Blue);
    Draw.VerticalLine(this, "CurrentDayeg"+k, Time[1], Brushes.Red);
    //Print(hpivot +" "+ High[0] +" "+ Low[0]);
    						k++;
    						Draw.Line(this, "MissedPivot"+k, false, CurrentDayBegin, hpivot, CurrentDayEnd, hpivot, DayPivotColor , DashStyleHelper.Solid,2);
    						StoreMP(hpivot,PivotBegin); 
    						CalcButUnstored		=	false;
    					}
    Attached Files
    Last edited by stearno; 03-11-2016, 02:30 AM.

    #2
    Hello stearno,

    Thank you for your post.

    If the Open should be used at the time of Times[1][1] then you need to set it then. Currently you are setting it when the following condition is true:
    Code:
    if(hpivot > High[0] || hpivot < Low[0])
    Will that condition always return true on the open of the day?
    You need to ensure the Open line you draw is truly the Opens[1][1] by drawing it as such.

    A simple fix could simply be the following:
    Code:
    				if(hpivot > High[0] || hpivot < Low[0])
    					{
    						Draw.Line(this, "Low"+k, false, PivotBegin, Low[0], PivotEnd, Low[0], Brushes.Yellow , DashStyleHelper.Solid,1);
    						Draw.Line(this, "Open"+k, false, PivotBegin, [B]Opens[1][1][/B], PivotEnd, Open[0], Brushes.Purple , DashStyleHelper.Solid,1);
    						Draw.Line(this, "High"+k, false, PivotBegin, High[0], PivotEnd, High[0], Brushes.Red , DashStyleHelper.Solid,1);
    						Draw.VerticalLine(this, "CurrentDayend"+k, Time[0], Brushes.Blue);
    						Draw.VerticalLine(this, "CurrentDayeg"+k, Time[1], Brushes.Red);
    						k++;
    						Draw.Line(this, "MissedPivot"+k, false, CurrentDayBegin, hpivot, CurrentDayEnd, hpivot, DayPivotColor , DashStyleHelper.Solid,2);
    						StoreMP(hpivot,PivotBegin); 
    						CalcButUnstored		=	false;
    					}

    Comment


      #3
      No, that condition is not always true, but thst is as design.

      As to your second point, wouldn't I not need to do that for all of them (high, low, time, etc) ? And how could this be the problem because the code is inside the barsinprogress = 1, so it means that all references will be of the day candle.

      I just remind thst this code works in Nt7 as it is. So unless that point that need to use the series reference inside the high low close bars?

      If you say this still could be the problem I will put the series reference on all of them.

      Thanks,
      Stearno

      Comment


        #4
        So unless that point that need to use the series reference inside the high low close bars?
        Correct, I would implement the specific calls like Highs, Lows, Closes, etc.

        Comment


          #5
          Originally posted by NinjaTrader_PatrickH View Post
          Correct, I would implement the specific calls like Highs, Lows, Closes, etc.
          I did as you suggested. That might have fixed it. Thanks. But I will look closely at it and come back if anymore questions. Thanks for your help.

          -Stearno

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          580 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          335 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          102 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          552 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X