Laguerre PPO PercentileRank Mkt Tops & Bottoms

TETRIZ

New member
Hello, can any TOS expert help translate these tradingview codes into TOS codes? Looks like it's an interesting indicator. Thanks a lot:)

Link:
https://www.tradingview.com/script/...ilerank-mkt-tops-bottoms/#chart-view-comments
Check if below could work for you. Please do your extensive testing before put to use. I am not a rookie tos coder.

Code:
#Kudos & Gratitude to Chrismoody https://www.tradingview.com/script/ngr0qRmw-CM-Laguerre-PPO-PercentileRank-Mkt-Tops-Bottoms/

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

input wrnpctile = 70;# title="Percentile Threshold Warning Value, Exceeding Creates Colored Histogram")

input Short = 0.4 ;# title="PPO Setting")

input Long = 0.8 ;# title="PPO Setting")

input lkbT = 200;#,title="Look Back Period For 'Tops' Percent Rank is based off of?")

input lkbB = 200; #title="Look Back Period For 'Bottoms' Percent Rank is based off of?")

input sl = yes; #title="Show Threshold Line?")

input swl = yes;#title="Show Warning Threshold Line?")



script laguerre {

    input gamma = 0.2;

    input price = close;

    rec L0 = (1 - gamma) * price + gamma * L0[1];

    rec L1 = -gamma * L0 + L0[1] + gamma * L1[1];

    rec L2 = -gamma * L1 + L1[1] + gamma * L2[1];

    rec L3 = -gamma * L2 + L2[1] + gamma * L3[1];

    plot Filt = (L0 + 2 * L1 + 2 * L2 + L3) / 6;

    plot FIR = (price + 2 * price[1] + 2 * price[2] + price[3]) / 6;

}

;


def lmas = laguerre(Short, hl2).Filt;

def lmal = laguerre(Long, hl2).Filt;


def pctileB = pctile * -1;

def wrnpctileB = wrnpctile * -1;

#PPO Plot

def ppoT = ((lmas - lmal) / lmal) * 100 ;

def ppoB = ((lmal - lmas) / lmal) * 100;


# calculate the percent

# ---------------------------

def pctRankTT = fold i = 1 to lkbT + 1 with count = 0

do

  if ppoT > ppoT[i] then

    count + 1

  else

    count;

def pctRankT = Round((100 * pctRankTT / lkbT), 0);


def pctRankBB = fold j = 1 to lkbB + 1 with countj = 0

    do

          if ppoB > ppoB[j] then

                countj + 1

          else

               countj;

def pctRankB = (100 * pctRankBB / lkbB) * -1;


plot pctRankTP = if pctRankT then pctRankT * 1 else Double.NaN;# if pctRankB then (Round(pctRankB/lkbT*100.0) * -1) else double.naN;

pctRankTP.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

pctRankTP.AssignValueColor(if (pctRankT >= pctile) then Color.RED else if (pctRankT >= wrnpctile and pctRankT < pctile) then Color.DARK_ORANGE else Color.DARK_GRAY);

pctRankTP.SetLineWeight(2);


plot perct_B = if pctRankB then pctRankB  else Double.NaN;# if pctRankB then (Round(pctRankB/lkbT*100.0) * -1) else double.naN;

perct_B.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

perct_B.AssignValueColor(if (pctRankB <= pctileB) then CreateColor (23, 208, 23) else if (pctRankB <= wrnpctileB and pctRankB > pctileB) then Color.DARK_GREEN else CreateColor (98, 98, 98));

perct_B.SetLineWeight(2);


plot ZeroLineH = 0;

ZeroLineH.SetPaintingStrategy(PaintingStrategy.LINE);

ZeroLineH.AssignValueColor(CreateColor(134, 136, 138));

ZeroLineH.SetLineWeight(1);


# Extreme Move Percentile +ve Threshold Line

plot PEMPTLP = if sl and pctile then pctile  else Double.NaN ;

PEMPTLP.SetPaintingStrategy(PaintingStrategy.LINE);

PEMPTLP.AssignValueColor(Color.RED);

PEMPTLP.SetLineWeight(1);


# Warning Percentile +ve Threshold Line

plot PWPTLP = if swl and wrnpctile then wrnpctile  else Double.NaN ;

PWPTLP.SetPaintingStrategy(PaintingStrategy.LINE);

PWPTLP.AssignValueColor(Color.ORANGE);

PWPTLP.SetLineWeight(1);

# Extreme Move Percentile -ve Threshold Line

plot EMPTLP = if sl and pctileB then pctileB  else Double.NaN ;

EMPTLP.SetPaintingStrategy(PaintingStrategy.LINE);

EMPTLP.AssignValueColor(Color.GREEN);

EMPTLP.SetLineWeight(1);

# Warning Percentile -ve Threshold Line

plot WPTLP = if swl and wrnpctileB then wrnpctileB  else Double.NaN ;

WPTLP.SetPaintingStrategy(PaintingStrategy.LINE);

WPTLP.AssignValueColor(Color.LIME);

WPTLP.SetLineWeight(1);

#-----
 

Thomas

Active member
VIP
Check if below could work for you. Please do your extensive testing before put to use. I am not a rookie tos coder.

Code:
#Kudos & Gratitude to Chrismoody https://www.tradingview.com/script/ngr0qRmw-CM-Laguerre-PPO-PercentileRank-Mkt-Tops-Bottoms/

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

input wrnpctile = 70;# title="Percentile Threshold Warning Value, Exceeding Creates Colored Histogram")

input Short = 0.4 ;# title="PPO Setting")

input Long = 0.8 ;# title="PPO Setting")

input lkbT = 200;#,title="Look Back Period For 'Tops' Percent Rank is based off of?")

input lkbB = 200; #title="Look Back Period For 'Bottoms' Percent Rank is based off of?")

input sl = yes; #title="Show Threshold Line?")

input swl = yes;#title="Show Warning Threshold Line?")



script laguerre {

    input gamma = 0.2;

    input price = close;

    rec L0 = (1 - gamma) * price + gamma * L0[1];

    rec L1 = -gamma * L0 + L0[1] + gamma * L1[1];

    rec L2 = -gamma * L1 + L1[1] + gamma * L2[1];

    rec L3 = -gamma * L2 + L2[1] + gamma * L3[1];

    plot Filt = (L0 + 2 * L1 + 2 * L2 + L3) / 6;

    plot FIR = (price + 2 * price[1] + 2 * price[2] + price[3]) / 6;

}

;


def lmas = laguerre(Short, hl2).Filt;

def lmal = laguerre(Long, hl2).Filt;


def pctileB = pctile * -1;

def wrnpctileB = wrnpctile * -1;

#PPO Plot

def ppoT = ((lmas - lmal) / lmal) * 100 ;

def ppoB = ((lmal - lmas) / lmal) * 100;


# calculate the percent

# ---------------------------

def pctRankTT = fold i = 1 to lkbT + 1 with count = 0

do

  if ppoT > ppoT[i] then

    count + 1

  else

    count;

def pctRankT = Round((100 * pctRankTT / lkbT), 0);


def pctRankBB = fold j = 1 to lkbB + 1 with countj = 0

    do

          if ppoB > ppoB[j] then

                countj + 1

          else

               countj;

def pctRankB = (100 * pctRankBB / lkbB) * -1;


plot pctRankTP = if pctRankT then pctRankT * 1 else Double.NaN;# if pctRankB then (Round(pctRankB/lkbT*100.0) * -1) else double.naN;

pctRankTP.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

pctRankTP.AssignValueColor(if (pctRankT >= pctile) then Color.RED else if (pctRankT >= wrnpctile and pctRankT < pctile) then Color.DARK_ORANGE else Color.DARK_GRAY);

pctRankTP.SetLineWeight(2);


plot perct_B = if pctRankB then pctRankB  else Double.NaN;# if pctRankB then (Round(pctRankB/lkbT*100.0) * -1) else double.naN;

perct_B.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

perct_B.AssignValueColor(if (pctRankB <= pctileB) then CreateColor (23, 208, 23) else if (pctRankB <= wrnpctileB and pctRankB > pctileB) then Color.DARK_GREEN else CreateColor (98, 98, 98));

perct_B.SetLineWeight(2);


plot ZeroLineH = 0;

ZeroLineH.SetPaintingStrategy(PaintingStrategy.LINE);

ZeroLineH.AssignValueColor(CreateColor(134, 136, 138));

ZeroLineH.SetLineWeight(1);


# Extreme Move Percentile +ve Threshold Line

plot PEMPTLP = if sl and pctile then pctile  else Double.NaN ;

PEMPTLP.SetPaintingStrategy(PaintingStrategy.LINE);

PEMPTLP.AssignValueColor(Color.RED);

PEMPTLP.SetLineWeight(1);


# Warning Percentile +ve Threshold Line

plot PWPTLP = if swl and wrnpctile then wrnpctile  else Double.NaN ;

PWPTLP.SetPaintingStrategy(PaintingStrategy.LINE);

PWPTLP.AssignValueColor(Color.ORANGE);

PWPTLP.SetLineWeight(1);

# Extreme Move Percentile -ve Threshold Line

plot EMPTLP = if sl and pctileB then pctileB  else Double.NaN ;

EMPTLP.SetPaintingStrategy(PaintingStrategy.LINE);

EMPTLP.AssignValueColor(Color.GREEN);

EMPTLP.SetLineWeight(1);

# Warning Percentile -ve Threshold Line

plot WPTLP = if swl and wrnpctileB then wrnpctileB  else Double.NaN ;

WPTLP.SetPaintingStrategy(PaintingStrategy.LINE);

WPTLP.AssignValueColor(Color.LIME);

WPTLP.SetLineWeight(1);

#-----
https://tos.mx/fwzJf6D
 

Similar threads

Top