Help needed for the following market profile afl code

Hello team I’m using the market profile code that was shared by Algo Geek for which i thank them for sharing. Now i need some upgrade on the provided afl code . Like open price with the letter (O) and close price with (*) . And can you also add the volume profile respective to the TPO’s generated. Like the one in the link below

https://drive.google.com/open?id=0B-OGRZWRf1P9SjJJU0xLNnEyWUE

​Below i have attached the provided afl code. Can you please edit and update it .?

_SECTION_BEGIN(“MarketProfile”);
SetChartOptions(0,chartShowArrows|chartShowDates);
//------------------------------------------------------------------------------
//
// Formula Name: Market Profile
//

//Market Profile

PlotOHLC(Ref(O,-1),Ref(H,-1),Ref(L,-1),Ref(C,-1),“Price”,colorBlack,styleNoLine);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g", Ref(O,-1), Ref(H,-1), Ref(L,-1), Ref(C,-1) ));

EnMP2= ParamList(“MarketProfile”,“Letters|Solid|Lines”);
styleLines = ParamStyle(“Style”, styleLine, maskAll);

Type=ParamList(“Type”,“Price Profile|Volume Profile”);
Period= ParamList(“Base”,“Hourly|Daily|Weekly|Monthly”,1);

Den = Param(“Density”, 3, 0.25, 100, 0.25); // Resolution in terms of $
percent=Param(“Value Area”, 70, 1, 100, 1);
ViewTPOCount= ParamToggle(“Show TPO Count”, “No|Yes”,1);
ViewPOC = ParamToggle(“Show POC”, “No|Yes”,1);
ViewVALVAH = ParamToggle(“Show VAL VAH Line”, “No|Yes”,1);
Viewfill = ParamToggle(“Show VA Fill”, “No|Yes”,1);
Colorpoc=ParamColor(“Color POC”, colorYellow);
Colorfill=ParamColor(“Color Fill”, ColorRGB(20,40,60));

EnIB = ParamToggle(“Show Initial Balance”, “Yes|No”);
IBBars = Param(“Initial Balance Bars”, 2, 0, 10, 1);

if(Period==“Daily”){
BarsInDay = BarsSince(Day() != Ref(Day(), -1));
Bot = TimeFrameGetPrice(“L”, inDaily, 0);
Top = TimeFrameGetPrice(“H”, inDaily, 0);
Vol = TimeFrameGetPrice(“V”, inDaily, 0);
}

if(Period==“Hourly”){
BarsInDay = BarsSince(Minute() != Ref(Minute(), -1));
Bot = TimeFrameGetPrice(“L”, in5Minute, 0);
Top = TimeFrameGetPrice(“H”, in5Minute, 0);
Vol = TimeFrameGetPrice(“V”, in5Minute, 0);
}

if(Period==“Weekly”){
BarsInDay = BarsSince(DayOfWeek() < Ref( DayOfWeek(), -1 ));
Bot = TimeFrameGetPrice(“L”, inWeekly, 0);
Top = TimeFrameGetPrice(“H”, inWeekly, 0);
Vol = TimeFrameGetPrice(“V”, inWeekly, 0);
}

if(Period==“Monthly” ){
BarsInDay = BarsSince(Month() != Ref(Month(), -1));
Bot = TimeFrameGetPrice(“L”, inMonthly, 0);
Top = TimeFrameGetPrice(“H”, inMonthly, 0);
Vol = TimeFrameGetPrice(“V”, inMonthly, 0);
}

CurTop = HHV(H,BarsInDay+1);
Curbot = LLV(L,BarsInDay+1);
Range = Highest(Top-Bot);
TodayRange = Top - Bot;

AveRange = Sum(Top-Bot,30)/30;
LAveRange = AveRange[BarCount-1];

// Initialization
baseX = 0;
baseY = floor(Bot[0]/Den)*Den;
relTodayRange = 0;
firstVisBar = Status(“firstvisiblebar”);
lastVisBar = Status(“lastvisiblebar”);

D=.0005;
total=0;
totaldn=0;
totalup=0;
shiftup=0;
shiftdn=0;
startr=0;

for (j=0; j <= 100; j++) {
x[j] = 0;
}

i0 = 0;
i1 = 0;
for (i=0; i<BarCount; i++) {
if (BarsInDay[i] == 0 AND i < firstVisBar) {
i0 = i;
}
if (BarsInDay[i] == 0 AND i >= lastVisBar) {
i1 = i;
}
}

i1 = BarCount-1;
for (i=i0; i<=i1; i++) {
if (BarsInDay[i] == 0) {
baseX = i;
baseY = floor(Bot[i]/Den)*Den;
maxY = floor(Top[i]/Den)*Den;
relTodayRange = (maxY-baseY)/Den;

for (j=0; j <= relTodayRange; j++) {
  x[j] = 0;
}

}

range_x=lastVisBar-firstVisBar;
spread = Param("X Space", 112, 1, 200, 1);
tpl = Param("Time Per Letter (mins)", 30, 1, 360, 1);
Intervalmin=Interval()/60;
flt =Param("First Letter (Bars)", 1, 1, 60, 1);
teb=ParamToggle("To Each Bar","No|Yes");
Color=Param("Color Threshold",20,1,50,1);
stopg=0;
stopr=0;
new=0;

Voloumeunit=Vol[i]/LastValue(BarsInDay);

if (EnMP2 == “Letters”) {
for (j=0; j<= relTodayRange; j++) {
if (L[i] <= baseY+jDen AND H[i] >= baseY+jDen) {
PlotTextSetFont("", “Arial”, 6, BarCount-1, Close[ BarCount - 3 ], colorGreen, colorDefault, -20 );
PlotTextSetFont(“C”, “Arial”, 40, 100, 100, colorGreen, colorDefault, -20 );
PlotText(StrExtract(" A , B , C , D , E , F , G , H , I , J , K , L , M , N , O , P , Q , R , S , T , U , V , W , X , Y , Z, a , b , c , d , e , f , g , h , i , j , k , L , m , n ,o , p , q , r , s , t , u , v , w , x , y , z “,
IIf(BarsInDay[i]<flt,0,floor(BarsInDay[i]/(tpl/Intervalmin))-0)), baseX+IIf(teb==1,BarsInDay[i],x[j](range_x/spread)), baseY+jDen,
colorWhite,ColorHSB(10+((floor(BarsInDay[i]/(tpl/Intervalmin)))*Color),160,140));
x[j]++;
PlotTextSetFont(”", “Arial”, 10, BarCount-1, Close[ BarCount - 3 ], colorGreen, colorDefault, -20 );
}
}
}

else if (EnMP2 == “Lines” OR EnMP2 == “Solid”) {
for (j=0; j<= relTodayRange; j++) {
if (L[i] <= baseY+jDen AND H[i] >= baseY+jDen) {
if(Type==“Price Profile”){x[j]=x[j]+1;}
else if(Type==“Volume Profile”){x[j]=x[j]+round(V[i]/Voloumeunit);}

   }
}

}

// Draw Initial Balance after 11am bar is complete
if (BarsInDay[i] == IBBars AND EnIB == 0) {
Line1 = LineArray(i-2, curtop[i-1],i+7, curtop[i-1],0,True);
Plot(Line1,"",colorLightGrey,styleLine+styleDashed|styleNoRescale);
Line1 = LineArray(i-2, curbot[i-1],i+7, curbot[i-1],0,True);
Plot(Line1,"",colorLightGrey,styleLine+styleDashed|styleNoRescale);
}

// Examine x[j]
if ((i < BarCount - 1 AND BarsInDay[i+1] == 0) OR i == BarCount-1) {
maxXj = 0;
maxj = 0;
for (j=0; j<= relTodayRange; j++) {
if (maxXj < x[j]) {maxXj = x[j]; maxj = j; StaticVarSet(“Maxj”,j); new=j;
}
}
for ( n = 1; n <= relTodayRange; n++ ) {
total[n]=x[n]+total[n-1];
}
Value_area=(total[relTodayRange]*percent)/100;

for ( a = 1; a <= relTodayRange; a++ )
 {
    if(Maxj-a>0 AND Maxj+a<relTodayRange)
    {
        if(MaxXj+total[Maxj+a]-total[Maxj]+total[Maxj-1]-total[Maxj-(a+1)]>=Value_area) {shiftup=a; shiftdn=a; break;}
     }    
    else if(Maxj-a<1 ) 
    {
        if(MaxXj+total[Maxj+a]-total[Maxj]+total[Maxj-1]>=Value_area){shiftup=a; shiftdn=maxj-1; break;}        
       }
    else if(Maxj+a>relTodayRange ) 
    {
        if(MaxXj+total[relTodayRange]-total[Maxj]+total[Maxj-1]-total[Maxj-(a+1)] >=Value_area){shiftup=relTodayRange-maxj; shiftdn=a; break;}        
       }
 }

Vah = LineArray(baseX, baseY+(maxj+shiftup)*Den, i, baseY+(maxj+shiftup)*Den,0,True);
Val = LineArray(baseX, baseY+(maxj-shiftdn)*Den, i, baseY+(maxj-shiftdn)*Den,0,True);
poc = LineArray(baseX, baseY+maxj*Den, i, baseY+maxj*Den,0,True);
if(ViewVALVAH==1){Plot(Vah,"",ParamColor("Color_VA",  colorLightBlue),styleLine|styleNoRescale);
Plot(Val,"",ParamColor("Color_VA",  colorLightBlue),styleLine|styleNoRescale);}
if(ViewPOC==1){Plot(poc,"",Colorpoc,styleLine|styleNoRescale);}
PlotText(""+(baseY+(maxj+shiftup)*Den),i-5,baseY+(maxj+shiftup)*Den,colorWhite);
PlotText(""+(baseY+(maxj-shiftdn)*Den),i-5,baseY+(maxj-shiftdn)*Den,colorWhite);
if(ViewTPOCount==1){PlotText(""+total[maxj],basex,bot[i]-(Top[i]-bot[i])*0.05,ParamColor("Color_VAL", colorLavender));
PlotText(""+(total[relTodayRange]-total[maxj]),basex,Top[i]+(Top[i]*0.0005),ParamColor("Color_VAH", colorLavender));}

if(ViewPOC==1){PlotText(""+(baseY+maxjDen),i-5,baseY+maxjDen,Colorpoc);}
}

if (i < BarCount - 1 AND BarsInDay[i+1] == 0 OR i == BarCount-1) {

  for  (p = 1; p < relTodayRange+1; p++){
  line = LineArray(baseX, baseY+p*Den, baseX+x[p], baseY+p*Den);
  line2 = LineArray(baseX, baseY+(p-1)*Den, baseX+x[p-1], baseY+(p-1)*Den);

  if (EnMP2 == "Solid")
  {
  PlotOHLC( Line,  Line,  Line2, Line2, "",IIf(p>(maxj+shiftup),ParamColor("Color_VAH",  colorLavender),IIf(p<=(maxj+shiftup)AND p>(maxj-shiftdn),ParamColor("Color_VA", colorLightBlue),ParamColor("Color_VAL", colorLavender))) ,styleCloud|styleNoRescale|styleNoLabel);
  }
  if (EnMP2 == "Lines") 
  {
 Plot(line,"",IIf(p>(maxj+shiftup),ParamColor("Color_VAH", colorLavender),IIf(p<=(maxj+shiftup)AND p>(maxj-shiftdn),ParamColor("Color_VA", colorLightBlue),ParamColor("Color_VAL",  colorLavender))) , styleLines|styleNoLabel);
 }

}
if(Viewfill==1){PlotOHLC(Vah,Vah,Val,Val,"",Colorfill,styleCloud|styleNoRescale|styleNoLabel);}

}
}

_SECTION_END();

_SECTION_BEGIN(“Gradient Backfill”);
SetChartBkGradientFill( ParamColor(“BgTop”, ColorRGB( 0,0,0 )),

ParamColor(“BgBottom”, ColorRGB( 0,0,0 )),ParamColor(“titleblock”,ColorRGB( 192,192,192 )));
_SECTION_END();

In the above AFL the open price with  O   is already defined, For Volume Profile with respect to TPO , check the below AFL

_SECTION_BEGIN("TPO20060605");

Version(4.77);

//Edit starttime and endTradingday===================================================

starttime=093000;
endTradingday=161500;

//===================================================================================

SetChartBkColor(ParamColor("Chart Background",colorLightYellow));

Plot(C,"",ParamColor("Bar colour",colorLightGrey),styleBar);

SetBarsRequired(11000,11000);

function Slot(price,tick)
{
// used in Market Profile for allocating the right price slot
result=floor(price/tick)*tick;
  return result;
}

procedure BarIndexvalue(starttime,endtime,endTradingDay,Maxdays)
{
SetBarsRequired(10000,-1);

global endbar;
global startbar;
global startdate;
global enddate;

Trading_day=IIf(Now(4)>=starttime AND Now(4)<=endTradingDay AND Now(9) != 7 AND Now(9)!= 1,1,0); 
TimeFrameSet(inDaily);
startdate=LastValue(Ref(DateNum(),-Maxdays));
enddate=ValueWhen(TimeNum()==endtime,DateNum(),1);
enddate=LastValue(enddate);
TimeFrameRestore();
startdate=TimeFrameExpand(startdate,inDaily);
enddate=TimeFrameExpand(enddate,inDaily);
startbar=LastValue(ValueWhen(DateNum()==startdate AND TimeNum()==starttime,BarIndex(),1));
endbar=LastValue(ValueWhen(DateNum()==enddate AND TimeNum()==endtime,BarIndex(),1));

}

TPOtoday=ParamToggle("TPO for current day","Off|On",0);
TPOHistorical=ParamToggle("TPO: completed trading days", "Off | 1 m..3m..5 m..and 15 m");
TPOdisplay=ParamToggle("TPO display", "Default | +",0);
Maxdays=Param("TPO...V x P: Up to 22 days ago", 3,3,22,1); //TPO Calculated AND Plotted
VP_currentDay =ParamToggle("V x P real time","Off | On; better used on 1m chart",0);
MaxVPdays=Param("V x P real time: number of days",1,1,10,1);
Volume_Profile =ParamToggle("V x P to 22 days ago.","Off. Always off during mkt hours | On. Do a scan first",0);
Volume_Text=ParamToggle("V x P analysis","Off. Always off during mkt hours  | On; Do a scan first",0);
histowidth=Param("Histogram scaling",1500,500,5000,100);

if(TPOdisplay==0)
{
TPOtext= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()_+][}{;:.<>\|0" ;
TPOcolor=colorBlack;
}
else
{
TPOtext= "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" ;
TPOcolor=colorGreen;
}

TPOVOlume=">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";

MaxdaysVolProfile=23;	//Calculated elsewhere and retrieved

Lo=999999;
Hi=0;
SetInterval=2;

endtime=161500-(Interval()/60)*100;
endtime30m=endTradingday-1500;
PeakTPOLength=0;
PeakTPOrow=0;

Hiday=0;
Loday=999999;

Tick=IIf(Name()=="ES #F" OR Name()=="NQ #F", 0.25,IIf(Name()=="YM #F", 2.5,IIf(Name()=="AB #F", 20,1.0)));

Trading_day=IIf(Now(4)>=starttime AND Now(4)<=endTradingDay AND Now(9) !=7 AND Now(9)!= 1,1,0); 
Trading_day=LastValue(Trading_day);

TimeFrameSet(inDaily);
z=EndValue(BarIndex());
hi=H;
Lo=L;
if(Trading_day==1)
	{
		Hi[z]=H[z-1];
		Lo[z]=L[z-1];
	}
TimeFrameRestore();
Hi=TimeFrameExpand(Hi,inDaily, expandFirst);
Lo=TimeFrameExpand(Lo,inDaily, expandFirst);

firstbar=TimeNum()==starttime;

BarInt=Interval()/60;
Title=Name()+ " " + Interval()/60 +"m"+" " +"Y_High" + " " + Hi+ " " + "Y_Low"+ " " + Lo+" " + "Open: "+O+" " +"High: " +H+" " +"Low: "+L+" " +"Close: " +C;

HiLo=ParamToggle("Hi Lo"," Off|On ",0);
if(HiLo==1)
{
Plot(Hi,"Y_High",colorBlue, styleStaircase| styleThick ); 
Plot(Lo,"Y_Low",colorRed, styleStaircase| styleThick ); 
//Plot(Cv,"Y_C",11,styleLine | styleNoRescale);
}

Firstbarofday=ParamToggle("Show First bar of day", " No|Yes ",0);
if(Firstbarofday==1)
	{
		Plot(IIf(Trading_day==1,Null,firstbar),"",colorViolet,styleArea | styleOwnScale | styleNoRescale);
	}
BarIndexvalue(starttime,endtime,endTradingDay,Maxdays);

ntime=TimeNum();
ndate=DateNum();

TimeFrameSet(inDaily);
z=EndValue(BarIndex());
maxprice=(ceil(HHV(H,maxdays+1))/tick)*tick; 
minprice=(floor(LLV(L,Maxdays+1))/tick)*tick;
if(Trading_day==1)
	{
		Maxprice[z]=Maxprice[z-1];
		Minprice[z]=Minprice[z-1];
	}

TimeFrameRestore();
Maxprice=LastValue(TimeFrameExpand(Maxprice,inDaily,expandFirst));
Minprice=LastValue(TimeFrameExpand(Minprice,inDaily, expandFirst));

numprices=LastValue((maxprice-minprice)/tick+1);

if(TPOHistorical==1)
{

TPOTimeFrame=Setinterval*in15Minute;

TimeFrameSet(TPOTimeFRame);
Hi30m=H;
Lo30m=L;
BarID30m=BarsSince(Day() != Ref(Day(),-1));
Maxnumbar30m=LastValue(HHV(BarID30m,721));
TimeFrameRestore();
Hi30m=TimeFrameExpand(Hi30m,TPOTimeFrame, expandFirst);
Lo30m=TimeFrameExpand(Lo30m,TPOTimeFrame, expandFirst);
Maxnumbar30m=TimeFrameExpand(Maxnumbar30m,TPOTimeFrame);
BarID30m=TimeFrameExpand(BarId30m,TPOTimeFrame,expandFirst);

osInitialize();
TPO=osTabCreate();

osTabAddColumn("Price",1,TPO);

for (i=1; i<=Maxdays+1; i++)
	{
		osTabAddColumn("day" + NumToStr(i,1.0),2,TPO,88);
	}

for (i=0; i<numprices; i++)
	{	
			for (j=1;j<=Maxdays+1; j++)
			{
				osTabSetString("" ,i,j,TPO);
								
			}
	}

//setup prices in column 1 
    i=0;
	j=Maxprice;
	while (j>=Minprice)
		{  
			osTabSetNumber(j,i,0,TPO);
			j=j-tick;
          i=i+1;
		}      

nday=Maxdays+1;
it=1; 

for (barid=startbar; barid<=endbar; barid++)
			{
									
			if( ndate[barid]>ndate[barid-1] AND it != 1) 

					{	
						
						nday=nday-1;
					}

					it=it+1;	
						
					if(ntime[barid]>=starttime AND ntime[barid]<=endtime AND barid30m[barid] != barid30m[barid-1]  )
						{
						 
						numstick=(slot(Hi30m[barid],tick)-slot(Lo30m[barid],tick))/tick+1;
							Hi=slot(Hi30m[barid],tick);
							Lo=slot(Lo30m[barid],tick);
																
							j=Hi;
							while(j>=Lo)
								{
									row=(Maxprice-j)/tick;
									CellTPO=osTabGet(row,nday,TPO);
									y=BarID30m[barid];
									TPOSubset=	StrMid(TPOtext,y,1);
									CellTPO=CellTPO+ TPOSubset;
									
									osTabSetString(CellTPO,row,nday,TPO);
										if (StrLen(CellTPO)>PeakTPOLength[nday] )
										 { 
												PeakTPOLength[nday] = StrLen(CellTPO); 
												PeakTPOrow[nday]=row;
										 }

j=j-tick;
								}
						
						}	
						if(nday<=Maxdays) 
							{ 
								//TPOLength=PeakTPOLength[nday];
							 	TPOprice[nday]=osTabGet(PeakTPOrow[nday],0,TPO); 
							}
						if (Lo<LoDay[nday])
										 { 
												LoDay[nday] = Lo; 
												MinRow[nday]=(Maxprice-Lo)/tick;

										 }
						if (Hi>HiDay[nday])
										 { 
												HiDay[nday] = Hi; 
												Maxrow[nday]=(Maxprice-Hi)/tick;
										 }

}

ntime=TimeNum();

ndate=DateNum();
nday=Maxdays+1;

it=1; 
for (barid=startbar; barid<endbar-1; barid++)
			{

if( ndate[barid]>ndate[barid-1] AND it != 1) 

					{	
						
						nday=nday-1;
						
					}
					it=it+1;	

if (ntime[barid] == 111500)
				{
					for (i=0; i<numprices; i++)
						{		  
							Text=osTabGet(i,nday,TPO);
							price=osTabGet(i,0,TPO);
							if(StrLen(Text)==PeakTPOLength[nday]) {Text=Text+"  <<";}
							PlotText(Text,barid,price,TPOcolor);
									
						}
				}

}

osTabDelete(TPO);
}
MaxdaysVolProfile=23;

if((Volume_Profile==1 OR Volume_Text==1) AND trading_day==0)
{
pricetable=osTabCreate();

osTabAddColumn("Prices",1,pricetable);

		osTabAddColumn("day0",1,Pricetable);

for (i=1; i<=MaxdaysVolProfile; i++)
	{
		osTabAddColumn("day" + NumToStr(i,1.0),1,pricetable);
		
	}

osTabImport("pricetable.txt",",",pricetable);
//osTabExport("pricetest.txt",",",pricetable);

SetForeign("~Volume_Profile");
Openprice=O;
Closeprice=C;
POC=H;
VWAP=floor(L)+round(frac(L)/tick)*tick;
VolumeAbovePOC=V;
RestorePriceArrays();

SetForeign("~Volume_Profile_2");
UVAvol=O;
LVAVol=C;
ExactTreshold=H;
VolumeBelowPOC=V;
Peakvol=OI;
RestorePriceArrays();
printf("Volume above POC  "); printf(NumToStr(VolumeAbovePOC,1.3));
printf("\n");
printf("Volume below POC  "); printf("\n");
printf(NumToStr(VolumeBelowPOC,1.3));
printf("\n");
printf("Exact Treshold");
printf("\n");
printf(NumToStr(ExactTreshold ,1.3));
printf("\n");
printf("Peak Volume");
printf("\n");
printf(NumToStr(Peakvol ,1.3));
printf("\n");
printf("POC ");
printf(NumToStr(POC,1.2));
printf("\n");
printf("UVA ");
printf(NumToStr(UVAVol,1.2));
printf("\n");
printf("LVA ");
printf(NumToStr(LVAVol,1.2));
printf("\n");
printf("VWAP ");
printf(NumToStr(VWAP,1.2));

PlotShapes(IIf(TimeNum()==starttime,shapeSquare,shapeNone),colorYellow,0,O,0);
PlotShapes(IIf(TimeNum()==endtime,shapeStar,shapeNone),colorViolet,0,C,0);

nday=Maxdays+1;

TimeFrameSet(inDaily);
z=EndValue(BarIndex());
maxprice=(ceil(HHV(H,MaxdaysVolProfile))/tick)*tick; 
minprice=(floor(LLV(L,MaxdaysVolProfile))/tick)*tick;
if(Trading_day==1)
	{
		Maxprice[z]=Maxprice[z-1];
		Minprice[z]=Minprice[z-1];
	}

TimeFrameRestore();
Maxprice=LastValue(TimeFrameExpand(Maxprice,inDaily,expandFirst));
Minprice=LastValue(TimeFrameExpand(Minprice,inDaily, expandFirst));

numprices=LastValue((maxprice-minprice)/tick+1);

it=1; 
if(Volume_Text==1)
{
for (barid=startbar; barid<=endbar; barid++)
			{

if( ndate[barid]>ndate[barid-1] AND it != 1) 

{	
						
						nday=nday-1;
						
					}
					it=it+1;	

if (ntime[barid] == 094500)
				{
					for (i=0; i<numprices; i++)
						{		  

Text=NumToStr(osTabGet(i,nday,pricetable),1.0);
							price=osTabGet(i,0,pricetable);
							if(price==POC[barid]) 
								{
									Colorbkgnd=colorAqua;
								} 
							else 
								{ 
									
									if(price==VWAP[barid]) 
										{
											Colorbkgnd=colorYellow;
										}
									 else 	
										{
											if(price==UVAvol[barid] OR price==LVAvol[barid]) 
											{
												colorbkgnd=ColorRGB(255,0,255);
											}
											else
											{ 
												Colorbkgnd=colorWhite;
											}
										}
								}
					
							  if(text !="0") {PlotText(Text,barid,price,colorBlack,colorbkgnd);}
														
						}
				}
				if (ntime[barid] == 103000)
				{

for (i=0; i<numprices; i++)
						{		  
							if(nday%2) {Color=colorBlue;} else {Color=colorRed;}
							Text=osTabGet(i,nday,PriceTable);
							text=round(Text/(histowidth));
							if(text>110) {text=110;}
							Text=StrMid(TPOVolume,0,text);
							price=osTabGet(i,0,PriceTable);
							PlotText(Text,barid,price,color);
									
						}

}

}
}
else
{

for (barid=startbar; barid<=endbar; barid++)
			{

if( ndate[barid]>ndate[barid-1] AND it != 1) 

{	
						
						nday=nday-1;
						
					}
					it=it+1;	

if (ntime[barid] == 093000)
				{

for (i=0; i<numprices; i++)
						{		  
							
							Text=osTabGet(i,nday,PriceTable);
							if(nday%2) {Color=colorBlue;} else {Color=colorRed;}
							text=round(Text/histowidth);
							if(text>110) {text=110;}
							Text=StrMid(TPOVolume,0,text);
							price=osTabGet(i,0,PriceTable);
							PlotText(Text,barid,price,color);
									
						}

}

}

}

osTabDelete(pricetable);

}

if (TPOtoday==1)
{

TimeFrameSet(inDaily);
maxprice=(ceil(HHV(H,maxdays+1))/tick)*tick; 
minprice=(floor(LLV(L,Maxdays+1))/tick)*tick;
TimeFrameRestore();
Maxprice=LastValue(TimeFrameExpand(Maxprice,inDaily,expandFirst));
Minprice=LastValue(TimeFrameExpand(Minprice,inDaily, expandFirst));

numprices=LastValue((maxprice-minprice)/tick+1);

TPOTimeFrame=Setinterval*in15Minute;

TimeFrameSet(TPOTimeFRame);
Hi30m=H;
Lo30m=L;
BarID30m=BarsSince(TimeNum()<Ref(TimeNum(),-1)); 
Maxnumbar30m=LastValue(HHV(BarID30m,721));
TimeFrameRestore();
Hi30m=TimeFrameExpand(Hi30m,TPOTimeFrame, expandFirst);
Lo30m=TimeFrameExpand(Lo30m,TPOTimeFrame, expandFirst);
Maxnumbar30m=TimeFrameExpand(Maxnumbar30m,TPOTimeFrame);
BarID30m=TimeFrameExpand(BarId30m,TPOTimeFrame,expandFirst);

ntime=TimeNum();

osInitialize();
TPO1day=osTabCreate();

osTabAddColumn("Price",1,TPO1day);
osTabAddColumn("day0",2,TPO1day,88);

for (i=0; i<numprices; i++)
	{	
  		osTabSetString("" ,i,1,TPO1day);
	}

//setup prices in column 1 
    i=0;
	j=Maxprice;
	while (j>=Minprice)
		{  
			osTabSetNumber(j,i,0,TPO1day);
			j=j-tick;
          i=i+1;
		}      

nday=1;

ndate=DateNum();
endbar=LastValue(BarIndex());
startbar=LastValue(ValueWhen(TimeNum()==starttime,BarIndex(),1));

for (barid=startbar; barid<=endbar; barid++)
			{
									
				if(ntime[barid]>=starttime AND ntime[barid]<=endtime AND barid30m[barid] != barid30m[barid-1]  )
						{
						 
						numstick=(slot(Hi30m[barid],tick)-slot(Lo30m[barid],tick))/tick+1;
							Hi=slot(Hi30m[barid],tick);
							Lo=slot(Lo30m[barid],tick);
																
							j=Hi;
							while(j>=Lo)
								{
									row=(Maxprice-j)/tick;
									CellTPO=osTabGet(row,nday,TPO1day);
									y=BarID30m[barid];
									TPOSubset=	StrMid(TPOtext,y,1);
									CellTPO=CellTPO+ TPOSubset;
									
									osTabSetString(CellTPO,row,nday,TPO1day);
																				
									j=j-tick;
								}
						
						}	

}

//osTabExport("TPO1day.txt",",",TPO1day);

for (barid=startbar; barid<endbar-1; barid++)
			{
					
				if (ntime[barid] == 093000)
				{
					for (i=0; i<numprices; i++)
						{		  
							
							Text=osTabGet(i,nday,TPO1day);
							price=osTabGet(i,0,TPO1day);
							PlotText(Text,barid,price,colorBlue);
									
						}
				}

}

osTabDelete(TPO1day);

}
Previous_Values=ParamToggle("Previous values","Off | On; Do scan first",0);
if(Previous_values==1)
{
SetForeign("~Volume_Profile");
//Openprice=TimeFrameGetPrice("O",inDaily,-1);
//Closeprice=TimeFrameGetPrice("C",inDaily,-1);
POC=TimeFrameGetPrice("H",inDaily,-1);
L=floor(L)+round(frac(L)/tick)*tick;
VWAP=TimeFrameGetPrice("L",inDaily,-1);
VolumeAbovePOC=TimeFrameGetPrice("V",inDaily,-1);
RestorePriceArrays();

SetForeign("~Volume_Profile_2");
UVAvol=TimeFrameGetPrice("O",inDaily,-1);
LVAVol=TimeFrameGetPrice("C",inDaily,-1);
ExactTreshold=TimeFrameGetPrice("H",inDaily,-1);
VolumeBelowPOC=TimeFrameGetPrice("V",inDaily,-1);
Peakvol=TimeFrameGetPrice("I",inDaily,-1);
RestorePriceArrays();
UVAvol=IIf(UVAvol==0,Null,UVAvol);
LVAvol=IIf(LVAvol==0,Null,LVAvol);
POC=IIf(POC==0,Null,POC);
VWAP=IIf(VWAP==0,Null,VWAP);

Plot(UVAvol,"UVA",11,styleDots | styleNoRescale);
Plot(LVAvol,"LVA",11,styleDots | styleNoRescale);
Plot(POC,"POC",colorTurquoise,styleDots | styleNoRescale);
Plot(VWAP,"VWAP",colorGreen,styleDots | styleNoRescale);
PlotShapes(IIf(TimeNum()==starttime,shapeSquare,shapeNone),colorYellow,0,O,0);
PlotShapes(IIf(TimeNum()==endtime,shapeStar,shapeNone),colorViolet,0,C,0);

}
Latest_Values=ParamToggle("Current values","Off | On; Do a scan first",0);
if(Latest_values==1)
{
SetForeign("~Volume_Profile");
//Openprice=TimeFrameGetPrice("O",inDaily,0);
//Closeprice=TimeFrameGetPrice("C",inDaily,0);
POC=TimeFrameGetPrice("H",inDaily,0);
L=floor(L)+round(frac(L)/tick)*tick;
VWAP=TimeFrameGetPrice("L",inDaily,0);
VolumeAbovePOC=TimeFrameGetPrice("V",inDaily,0);
RestorePriceArrays();

SetForeign("~Volume_Profile_2");
UVAvol=TimeFrameGetPrice("O",inDaily,0);
LVAVol=TimeFrameGetPrice("C",inDaily,0);
ExactTreshold=TimeFrameGetPrice("H",inDaily,0);
VolumeBelowPOC=TimeFrameGetPrice("V",inDaily,0);
Peakvol=TimeFrameGetPrice("I",inDaily,0);
RestorePriceArrays();

UVAvol=IIf(UVAvol==0,Null,UVAvol);
LVAvol=IIf(LVAvol==0,Null,LVAvol);
POC=IIf(POC==0,Null,POC);
VWAP=IIf(VWAP==0,Null,VWAP);

Plot(UVAvol,"UVA",11,styleDots | styleNoRescale);
Plot(LVAvol,"LVA",11,styleDots | styleNoRescale);
Plot(POC,"POC",colorTurquoise,styleDots | styleNoRescale);
Plot(VWAP,"VWAP",colorGreen,styleDots | styleNoRescale);
PlotShapes(IIf(TimeNum()==starttime,shapeSquare,shapeNone),colorYellow,0,O,0);
PlotShapes(IIf(TimeNum()==endtime,shapeStar,shapeNone),colorViolet,0,C,0);

}

if(VP_currentDay==1 )
{

TimeFrameSet(inDaily);
z=EndValue(BarIndex());
maxprice=(ceil(HHV(H,MaxVPdays+1))/tick)*tick; 
minprice=(floor(LLV(L,MaxVPdays+1))/tick)*tick;
TimeFrameRestore();
Maxprice=LastValue(TimeFrameExpand(Maxprice,inDaily,expandFirst));
Minprice=LastValue(TimeFrameExpand(Minprice,inDaily, expandFirst));

numprices=LastValue((maxprice-minprice)/tick+1);

osInitialize();

PriceTable2=osTabCreate();
	osTabAddColumn("Prices",1,PriceTable2);

for (i=1;i<=maxVPdays;i++)
	{
		osTabAddColumn("day" + NumToStr(i,1.0),1,PriceTable2);
	}

	for (i=0; i<numprices; i++)
	{	
			for (j=1;j<=MaxVPdays; j++)
			{
				osTabSetNumber(0,i,j,PriceTable2);
			}
	}
 //setup prices in column 1 
    i=0;
	j=Maxprice;
	while (j>=Minprice )
		{  
			osTabSetNumber(j,i,0,PriceTable2);
			j=j-tick;
          i=i+1;
		}      
TimeFrameSet(in1Minute);

ndate=DateNum();
endbar=LastValue(BarIndex());
startbar=LastValue(ValueWhen(TimeNum()==starttime,BarIndex(),MaxVPdays));

ndate=DateNum();
nday=MaxVPdays;
it=1; 

		for (barid=startbar; barid<=endbar; barid++)
			{
					
				if( ndate[barid]>ndate[barid-1] AND it != 1) 

					{	
						nday=nday-1;
					}

it=it+1;	
						
						numstick=(slot(H[barid],tick)-slot(L[barid],tick))/tick+1;
							Vol=V[barid]/numstick;
							Hi=slot(H[barid],tick);
							Lo=slot(L[barid],tick);

j=Hi;
							while(j>=Lo)
								{
									row=(Maxprice-j)/tick;
									Cellvol=osTabGet(row,nday,PriceTable2);
									Cellvol=Cellvol+Vol;
									osTabSetNumber(Cellvol,row,nday,PriceTable2);
									j=j-tick;
								}

}

numprices=LastValue((maxprice-minprice)/tick+1);
it=1;
nday=MaxVPdays;

for (barid=startbar; barid<=endbar; barid++)
			{

if( ndate[barid]>ndate[barid-1] AND it != 1) 

{	
						
						nday=nday-1;
						
					}
					it=it+1;	

if (ntime[barid] == 093000)
				{

for (i=0; i<numprices; i++)
						{		  
							if(nday%2) {Color=colorGreen;} else {Color=colorRed;}
							Text=osTabGet(i,nday,PriceTable2);
							text=round(Text/histowidth);
							if(text>110) {text=110;}
							Text=StrMid(TPOVolume,0,text);
							price=osTabGet(i,0,PriceTable2);
							PlotText(Text,barid,price,color);
									
						}

}

}

osTabDelete(PriceTable2);
}

_SECTION_END();
1 Like

Can someone please help with this question.???

Hello Algo geek
Thanks for the great help
But when i try this in my ami, i gives me an error saying “incorrect\espace sequence, Supported sequence are \n,\r,\t,” and \(gives single backshlash)" or something like error 54
Can you please help me with this
Regards
Pavan

you can ignore and can give comment to that line, ( might be not copied properly)

After saving the above afl code, I tried to drag and drop the above afl code in to my ami but it gives me an error, I even checked with all time frames still the same issue (error 54). what mite be the reason .?? Can you please help
Regards
Pavan

Below i have attched the error message screen shot please have a look at it.
https://drive.google.com/open?id=0B-OGRZWRf1P9ZkpSMm5KS0JaVU0
will be waiting for your reply
Pavan