Renko Chart Error

Hello,

I am not able to plot renko chart, i have set required bars but also ERROR 10 out of range subscript.

Also when i change interval it is not able to plot chart. please check.

And changing brick value whole chart goes wrong.

and how to get date and time of each renko brick.

Please check code and reply.



_SECTION_BEGIN("Renko");

SetBarsRequired(10000,10000);

Bricksize = Param("Bricksize",0.5,0.05,10000,0.05);
Changedir = Bricksize*2;

CF = ceil(H/Bricksize)*Bricksize;
CR = floor(L/Bricksize)*Bricksize;


j=2;

RC[0]=RH[0]=O[1];
RO[0]=RL[0]=RC[0]+Bricksize;

down[1]=1;
up[1]=0;

dt=DateTime();


for(i=1;i<BarCount-1;i++)

{
	if(CF[i]<=RC[j]-Bricksize) // Downtrend Continued
	
		{
			
			num=RC[j]-CF[i];
			
			for(x=1;x<=num;x++) // Continue down brick formation
			{
				j++;
				up[j+1]=0;
				down[j]=1;
				RC[j]=RC[j-1]-Bricksize;
				RO[j]=RC[j]+Bricksize;
				RDT[j]=dt[i];		
			
			}
			
		}
	
	
	if(CR[i]>=RC[j]+Bricksize ) // Uptrend Continued
	
		{
			
			num=CR[i] - RC[j];
			
			for(x=1;x<=num;x++) // Continue Up brick formation
			{
				j++;

				RC[j]=RC[j-1]+Bricksize;
				RO[j]=RC[j]-Bricksize;
				RDT[j]=dt[i];		
			
			}
			
		}
	
	if(CF[i]<=(RC[j]-Changedir)) // Change Up to Down
		
		{
			j++	;						//Changed Up to Down	
			RC[j]=RC[j-1]-Changedir;
			RO[j]=RC[j]+Bricksize;
			RDT[j]=dt[i];
			num=RC[j]-CF[i];
			
			for(x=2;x<=num;x++) // Continue down brick formation
			{
				j++;
				up[j]=0;
				down[j]=1;
				RC[j]=RC[j-1]-Bricksize;
				RO[j]=RC[j]+Bricksize;
				RDT[j]=dt[i];		
			
			}
			
		}
	
	if(CR[i]>=(RC[j]+Changedir)) // Change Down to up
	
	{
	
			j++	;						//Changed Down To Up
			RC[j]=RC[j-1]+Changedir;
			RO[j]=RC[j]-Bricksize;
			RDT[j]=dt[i];
			num=CF[i]-RC[j];
			
			for(x=2;x<=num;x++) // Continue Up brick formation
			{
				j++;
				RC[j]=RC[j-1]+Bricksize;
				RO[j]=RC[j]-Bricksize;
				RDT[j]=dt[i];		
			
			}
	
	}
	

}

PlotOHLC(RO,Max(RO,RC),Min(RO,RC),RC,"Renko Chart",colorDefault,styleCandle);



_SECTION_END();

image

i have not test the code but you are using debugger which has different bar settings and interval than chart, so the 10000 is not going to be used there. check the debugger settings, as 200 i remember as default bars that are showing in your image.

And also you can use SbrAll for 10000 future bars

1 Like

@Tomasz @travick @nsm51 can you have look on code and get what is wrong. In the code

Check difference in Renko chart (Like Range in Bar) and Actual Price.
image