Laguerre PPO PercentileRank Mkt Tops & Bottoms

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);

#-----
 
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
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Thread starter Similar threads Forum Replies Date
W ST RSI Laguerre Version Recommendations Questions 1

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
566 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top