Get 15 min information in any chart Scale

hi everyone..

i want to get info in 15 min on screen , the problem is the information change by change the chart Scale even I used TimeFrameSet(in15Minute);


Plot( C, "Price", IIf( O > C,colorDarkRed, colorDarkGreen ), styleCandle );

TimeFrameSet(in15Minute);
for( i = 0; i < 4 AND i < BarCount; i++ )
{
	
  		 	Bh =  ( C - L );
			Sh = ( H - C ) ;
			PHour = Sum(Bh , 4 );
			NHour = Sum(Sh , 4 ) ;
			Bp_Hour = 100 * PHour / (PHour + NHour) ;
			Sp_Hour =  100 * NHour / (PHour + NHour) ;
			BVMAHour = MA(Bh , 4 );
			BHourCHG = (( BVMAHour - Ref(BVMAHour, -1)) /  (Ref(BVMAHour, -1))*100) ;	
					
}

for( i = 0; i < 20 AND i < BarCount; i++ ) 
{
		 	Bd = ( C - L ) ;
			Sd = ( H - C ) ;
			PDay = Sum(Bd , 20 );
			NDay = Sum(Sd , 20 ) ;
			BVp_Day = 100 * PDay / (PDay + NDay) ;
			SVp_Day =  100 * NDay / (PDay + NDay) ;
			BVMADay = MA(Bd , 20 );
			BDayCHG = (( BVMADay - Ref(BVMADay, -1)) /  (Ref(BVMADay, -1))*100) ;
}	
TimeFrameRestore(); 			
	
			FS = (Status("pxchartwidth") + Status("pxchartheight"));
			Yx1 = Status("pxchartleft") ; 
			Yy1 = Status("pxcharttop"); 
			Yx2 = Status("pxchartright"); 
			Yy2 = Status("pxchartbottom"); 
			Yx3 = Status("pxchartwidth"); 
			Yy3 = Status("pxchartwidth"); 
			GfxSelectFont( "Times New Roman",FS*0.0045, 800 );
			GfxSetTextColor ( colorBrightGreen ); 
			GfxTextOut( WriteVal(PHour,1.2 ),YX2*0.003,YY2*0.140);
			GfxSelectFont( "Times New Roman",FS*0.0045, 800 );
			GfxSetTextColor ( colorBrightGreen ); 
			GfxTextOut( WriteVal(NHour,1.2 ),YX2*0.003,YY2*0.168);
			GfxSelectFont( "Times New Roman",FS*0.0045, 800 );
			GfxSetTextColor ( colorRose ); 
			GfxTextOut( WriteVal(PDay,1 ),YX2*0.003,YY2*0.200);
			GfxSelectFont( "Times New Roman",FS*0.0045, 800 );
			GfxSetTextColor ( colorRose ); 
			GfxTextOut( WriteVal(NDay,1.2 ),YX2*0.003,YY2*0.230);

Have you Read the manual regarding TimeFrame Functions?

Since you have not mentioned anywhere, it is worthy of noting that TimeFrame Functions will not access data of a "Lower" Timeframe than the chart interval.

So when you are accessing the 15 Min, what is the Chart interval ?

Also, I feel the way you have used the FOR Loops is not the right way.
If the variables are overwritten by the last iteration, then whats the point of the loop?
You can Reference the array directly with a specific BarIndex.

@Deserthawk
Why using loop when not using " i " & where TimeFrameExpand after TimeFrameRestore.