Please help and check wheather the coding i have done is correct or not

hmsanil

Active Member
#1
Hi all

The code given below is CM_LAGUERRE PPO PERCENTILERANK - MARKETS TOPPING from tradingview.com

Code:
//Created by ChrisMoody on 10/28/2014...Original PPO Code Created by TheLark
//Great for Spotting Tops.
study(title = "CM_Laguerre PPO PercentileRank", overlay=false)
pctile = input(90, title="Percentile Threshold Extreme Value, Exceeding Creates Colored Histogram")
wrnpctile = input(70, title="Percentile Threshold Warning Value, Exceeding Creates Colored Histogram")
Short = input(0.4, title="PPO Setting")
Long = input(0.8, title="PPO Setting")
lkb = input(200,title="Look Back Period Percent Rank is based off of?")
sl=input(true,title="Show Threshold Line?")
swl=input(true,title="Show Warning Threshold Line?")

//Laguerre PPO Code from TheLark
lag(g, p) =>
    L0 = (1 - g)*p+g*nz(L0[1])
    L1 = -g*L0+nz(L0[1])+g*nz(L1[1])
    L2 = -g*L1+nz(L1[1])+g*nz(L2[1])
    L3 = -g*L2+nz(L2[1])+g*nz(L3[1])
    f = (L0 + 2*L1 + 2*L2 + L3)/6
    f
lmas = lag(Short, hl2)
lmal = lag(Long, hl2)
//PPO Plot
ppo = (lmas - lmal)/lmal*100
//PercentRank of PPO 
pctRank = percentrank(ppo, lkb)
//Color Definition of Columns
col = pctRank >= pctile ? red : pctRank >= wrnpctile and pctRank < pctile ? orange : gray
//Plot Statements.
plot(pctRank,title="Percentile Rank Columns", color=col,style=columns,linewidth=2)
plot(sl and pctile ? pctile : na, title="Extreme Move Percentile Threshold Line", color=red, style=linebr, linewidth=4)
plot(swl and wrnpctile ? wrnpctile : na, title="Warning Percentile Threshold Line", color=orange, style=line, linewidth=4)


I am trying to convert into afl code with partial afl code taken from marketcalls,

Please check it out whether the conversions from trading view code to afl is correct or not





//Tradingview code

pctile = input(90, title="Percentile Threshold Extreme Value, Exceeding Creates Colored Histogram")

sl=input(true,title="Show Threshold Line?")

pctRank = percentrank(ppo, lkb)

//Color Definition of Columns
col = pctRank >= pctile ? red : pctRank >= wrnpctile and pctRank < pctile ? orange : gray

//Plot Statements.
plot(pctRank,title="Percentile Rank Columns", color=col,style=columns,linewidth=2)
plot(sl and pctile ? pctile : na, title="Extreme Move Percentile Threshold Line", color=red, style=linebr, linewidth=4)
plot(swl and wrnpctile ? wrnpctile : na, title="Warning Percentile Threshold Line", color=orange, style=line, linewidth=4)


//Afl code

pctile = 90;

sl=1;

pctRank = percentrank(ppo, lkb);

//Color Definition of Columns
Col=IIf(pctRank >= pctile,colorRed,IIf(pctRank >= wrnpctile and pctRank < pctile,colorOrange,colorGrey50));

//Plot Statements.
plot(pctRank,title="Percentile Rank Columns", color=col,styleHistogram | styleThick);
plot(sl and pctile , title="Extreme Move Percentile Threshold Line", colorred,styleHistogram | styleThick);
plot(swl and wrnpctile , title="Warning Percentile Threshold Line",colorOrange,styleHistogram| styleThick);



It would of big help if anybody can please help

Thank you

Sudha
 

mastermind007

Well-Known Member
#2
Hi all

The code given below is CM_LAGUERRE PPO PERCENTILERANK - MARKETS TOPPING from tradingview.com

Code:
//Created by ChrisMoody on 10/28/2014...Original PPO Code Created by TheLark
//Great for Spotting Tops.
study(title = "CM_Laguerre PPO PercentileRank", overlay=false)
pctile = input(90, title="Percentile Threshold Extreme Value, Exceeding Creates Colored Histogram")
wrnpctile = input(70, title="Percentile Threshold Warning Value, Exceeding Creates Colored Histogram")
Short = input(0.4, title="PPO Setting")
Long = input(0.8, title="PPO Setting")
lkb = input(200,title="Look Back Period Percent Rank is based off of?")
sl=input(true,title="Show Threshold Line?")
swl=input(true,title="Show Warning Threshold Line?")

//Laguerre PPO Code from TheLark
lag(g, p) =>
    L0 = (1 - g)*p+g*nz(L0[1])
    L1 = -g*L0+nz(L0[1])+g*nz(L1[1])
    L2 = -g*L1+nz(L1[1])+g*nz(L2[1])
    L3 = -g*L2+nz(L2[1])+g*nz(L3[1])
    f = (L0 + 2*L1 + 2*L2 + L3)/6
    f
lmas = lag(Short, hl2)
lmal = lag(Long, hl2)
//PPO Plot
ppo = (lmas - lmal)/lmal*100
//PercentRank of PPO 
pctRank = percentrank(ppo, lkb)
//Color Definition of Columns
col = pctRank >= pctile ? red : pctRank >= wrnpctile and pctRank < pctile ? orange : gray
//Plot Statements.
plot(pctRank,title="Percentile Rank Columns", color=col,style=columns,linewidth=2)
plot(sl and pctile ? pctile : na, title="Extreme Move Percentile Threshold Line", color=red, style=linebr, linewidth=4)
plot(swl and wrnpctile ? wrnpctile : na, title="Warning Percentile Threshold Line", color=orange, style=line, linewidth=4)


I am trying to convert into afl code with partial afl code taken from marketcalls,

Please check it out whether the conversions from trading view code to afl is correct or not





//Tradingview code

pctile = input(90, title="Percentile Threshold Extreme Value, Exceeding Creates Colored Histogram")

sl=input(true,title="Show Threshold Line?")

pctRank = percentrank(ppo, lkb)

//Color Definition of Columns
col = pctRank >= pctile ? red : pctRank >= wrnpctile and pctRank < pctile ? orange : gray

//Plot Statements.
plot(pctRank,title="Percentile Rank Columns", color=col,style=columns,linewidth=2)
plot(sl and pctile ? pctile : na, title="Extreme Move Percentile Threshold Line", color=red, style=linebr, linewidth=4)
plot(swl and wrnpctile ? wrnpctile : na, title="Warning Percentile Threshold Line", color=orange, style=line, linewidth=4)


//Afl code

pctile = 90;

sl=1;

pctRank = percentrank(ppo, lkb);

//Color Definition of Columns
Col=IIf(pctRank >= pctile,colorRed,IIf(pctRank >= wrnpctile and pctRank < pctile,colorOrange,colorGrey50));

//Plot Statements.
plot(pctRank,title="Percentile Rank Columns", color=col,styleHistogram | styleThick);
plot(sl and pctile , title="Extreme Move Percentile Threshold Line", colorred,styleHistogram | styleThick);
plot(swl and wrnpctile , title="Warning Percentile Threshold Line",colorOrange,styleHistogram| styleThick);



It would of big help if anybody can please help

Thank you

Sudha
you are on right track. Input in other language is to be substituted by Param function.
 

hmsanil

Active Member
#3
Thank you mastermind007 sir,

Thanks for your reply ,I have understood what you have said.

But still i feel i have done some mistake here(in plot statements)

In style i have used stylehistogram for all statements, but they have used column,linebr,line, i dont know what to use for the same in afl

plot(pctRank,title="Percentile Rank Columns", color=col,style=columns,linewidth=2)

plot(pctRank,title="Percentile Rank Columns", color=col,styleHistogram | styleThick);


plot(sl and pctile ? pctile : na, title="Extreme Move Percentile Threshold Line", color=red, style=linebr, linewidth=4)

plot(sl and pctile , title="Extreme Move Percentile Threshold Line", colorred,styleHistogram | styleThick);

plot(swl and wrnpctile ? wrnpctile : na, title="Warning Percentile Threshold Line", color=orange, style=line, linewidth=4)

plot(swl and wrnpctile , title="Warning Percentile Threshold Line",colorOrange,styleHistogram| styleThick);

And also in the below said code, is it correct way of defining ,means for true is it 1 or should i define it in some other way


sl=input(true,title="Show Threshold Line?")

sl=1;

Thank you

Sudha
 

KelvinHand

Well-Known Member
#4
Thank you mastermind007 sir,

Thanks for your reply ,I have understood what you have said.

But still i feel i have done some mistake here(in plot statements)

In style i have used stylehistogram for all statements, but they have used column,linebr,line, i dont know what to use for the same in afl

plot(pctRank,title="Percentile Rank Columns", color=col,style=columns,linewidth=2)

plot(pctRank,title="Percentile Rank Columns", color=col,styleHistogram | styleThick);


plot(sl and pctile ? pctile : na, title="Extreme Move Percentile Threshold Line", color=red, style=linebr, linewidth=4)

plot(sl and pctile , title="Extreme Move Percentile Threshold Line", colorred,styleHistogram | styleThick);

plot(swl and wrnpctile ? wrnpctile : na, title="Warning Percentile Threshold Line", color=orange, style=line, linewidth=4)

plot(swl and wrnpctile , title="Warning Percentile Threshold Line",colorOrange,styleHistogram| styleThick);

And also in the below said code, is it correct way of defining ,means for true is it 1 or should i define it in some other way


sl=input(true,title="Show Threshold Line?")

sl=1;

Thank you

Sudha
Wait for you all to convert, take very long time.:lol:
I convert, you fix & show me the chart that can see market top.

Code:
See #Post 6
 
Last edited:

hmsanil

Active Member
#5
Thank you KelvinHand Sir,

Sir, Dont mistake me.

Sir,I did not intend to find top of market. Marketcalls had given laugeree ppo indicator and he had mentioned that afl code is translated from tradingview site. While going through that i found this perecentrank indicator. So i tried myself to convert that indicator into afl.

Thanks a lot i learnt some part of coding today.

Thank you

Sudha
 

KelvinHand

Well-Known Member
#6
Thank you KelvinHand Sir,

Sir, Dont mistake me.

Sir,I did not intend to find top of market. Marketcalls had given laugeree ppo indicator and he had mentioned that afl code is translated from tradingview site. While going through that i found this perecentrank indicator. So i tried myself to convert that indicator into afl.

Thanks a lot i learnt some part of coding today.

Thank you

Sudha
Thank for the hint, fixed the code, the chart smooth now.

PHP:
//Created by ChrisMoody on 10/28/2014...Original PPO Code Created by TheLark
//Great for Spotting Tops.

//study(title = "CM_Laguerre PPO PercentileRank", overlay=false)

/****
   Converted by Kelvinhand @20160123
 ****/
Version(6.0);
pctile = Param("Percentile Threshold Extreme Value, Exceeding Creates Colored Histogram", 90, 1, 999);
wrnpctile = Param("Percentile Threshold Warning Value, Exceeding Creates Colored Histogram", 70, 1,999);
pmShort = Param("PPO Setting - Short", 0.4, 0.1, 100, 0.1);
pmLong = Param("PPO Setting - Long",0.8, 0.1, 100, 0.1);
lkb = Param("Look Back Period Percent Rank is based off of?", 200, 3, 999);
sl=ParamToggle("Show Threshold Line?", "No|Yes", 1);
swl=ParamToggle("Show Warning Threshold Line?", "No|Yes", 1);

//Laguerre PPO Code from TheLark
/****
   Kelvinhand Inported from marketcall.in
 ****/
function lag(g,p) 
{

f[0]=L0[0] = L1[0] = L2[0] = L3[0] = 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000001;

	for(i=1;i<=BarCount-1;i++)
	{
		L0[i] = (1-g)*p[i]+g*L0[i-1];
		L1[i] = -g*L0[i]+L0[i-1]+g*L1[i-1];
		L2[i] = -g*L1[i]+L1[i-1]+g*L2[i-1];
		L3[i] = -g*L2[i]+L2[i-1]+g*L3[i-1];
		f[i] = (L0[i]+2*L1[i]+ 2*L2[i] + L3[i])/6;
	}

	return f;

}


lmas = lag(pmShort, (H+L)/2);
lmal = lag(pmLong, (H+L)/2);
//PPO Plot
ppo = (lmas - lmal)/lmal*100;

//PercentRank of PPO 
pctRank = percentrank(ppo, lkb);

//Color Definition of Columns
col = IIf(pctRank >= pctile, colorred, IIf(pctRank >= wrnpctile and pctRank < pctile,  colororange , colorgrey50));
        

//Plot Statements.
SetBarFillColor(col);
plot(pctRank,"Percentile Rank Columns", colorLightGrey, styleArea|styleThick, Null, Null, 0, -1);
PlotGrid(IIf(sl and pctile , pctile, Null), colorred, 10,4);
PlotGrid(IIf(swl and wrnpctile , wrnpctile, Null), colorOrange, 10,4);
 
Last edited:

KelvinHand

Well-Known Member
#9
Re: CM-Laguerre-PPO-PercentileRank-Mkt-Tops-Bottoms

Hi Kelvinhand,

Thanks for the great work...But I am getting some errors when i m trying to use this AFL. I am currently using Amibroker 5.5. While this AFL work on 5.5?? If not what is the solution , please help.
When Version(6.0) is specified at top of the page, means i don't bother version below. The Enhanced command is PlotGrid() not in the older version.

The error you faced is your problem, you find your solution yourself or get other people willing to help u.
I m person believe using latest software improvement to improve my life.
I never look back the old version anymore.
 
Last edited:

Similar threads