Laguerre Used for Stop Placement

ebtrader

New member
Here's a great way to use Laguerre for stop placement.

Code:
#Laguerre Filter created by TradeScripter
#Enhanced by EBTrader


AssignBackgroundColor(CreateColor(8, 0, 15));

input price = close;
input gamma = 0.2;

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];
def FIlt = (L0 + 2 * L1 + 2 * L2 + L3) / 6;
def FIR = (price + 2 * price[1] + 2 * price[2] + price[3]) / 6;

plot Plot1 = FIlt;
plot Plot2 = FIR;

#Plot1.SetDefaultColor(color.red);
#Plot2.SetDefaultColor(color.blue);
Plot1.AssignValueColor(if Filt > FIlt[1] then Color.GREEN else Color.RED);

Plot2.AssignValueColor(if FIR  > FIlt and FIR > FIR[1]  then Color.GREEN else if FIR < FIlt and FIR < FIR[1] then Color.RED else Color.WHITE);


#AssignPriceColor(if FIR  > FIlt and FIR > FIR[1]  then Color.GREEN else if FIR < FIlt and FIR < FIR[1] then Color.RED else Color.WHITE);

UuKHZ0U.png
 
Last edited:

markos

Well-known member
VIP
Not necessarily, I have seen it in other scripts this low, but more often, I've seen it above 70. It may be script dependent,
 

ebtrader

New member
here is a version that can put more than one gamma setting on the same chart.

Code:
#Laguerre Filter created by TradeScripter
#Enhanced by EBTrader


AssignBackgroundColor(CreateColor(8, 0, 15));

input price = close;
input gamma = 0.2;

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];
def FIlt = (L0 + 2 * L1 + 2 * L2 + L3) / 6;
def FIR = (price + 2 * price[1] + 2 * price[2] + price[3]) / 6;

plot Plot1 = FIlt;
plot Plot2 = FIR;


Plot1.AssignValueColor(if Filt > FIlt[1] then Color.GREEN else Color.RED);

Plot2.AssignValueColor(if FIR  > FIlt and FIR > FIR[1]  then Color.GREEN else if FIR < FIlt and FIR < FIR[1] then Color.RED else Color.WHITE);

#Laguerre 2

input price2 = close;
input gamma2 = 0.2;

rec L00 = (1 - gamma2) * price2 + gamma2 * L00[1];
rec L11 = -gamma2 * L00 + L00[1] + gamma2 * L11[1];
rec L22 = -gamma2 * L11 + L11[1] + gamma2 * L22[1];
rec L33 = -gamma2 * L22 + L22[1] + gamma2 * L33[1];
def FIlt2 = (L00 + 2 * L11 + 2 * L22 + L33) / 6;
def FIR2 = (price2 + 2 * price2[1] + 2 * price2[2] + price2[3]) / 6;

plot Plot3 = FIlt2;
plot Plot4 = FIR2;


Plot3.AssignValueColor(if Filt2 > FIlt2[1] then Color.GREEN else Color.RED);

Plot4.AssignValueColor(if FIR2  > FIlt2 and FIR2 > FIR2[1]  then Color.GREEN else if FIR2 < FIlt2 and FIR2 < FIR2[1] then Color.RED else Color.WHITE);
 

markos

Well-known member
VIP
here is a version that can put more than one gamma setting on the same chart.

Code:
#Laguerre Filter created by TradeScripter
#Enhanced by EBTrader


AssignBackgroundColor(CreateColor(8, 0, 15));

input price = close;
input gamma = 0.2;

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];
def FIlt = (L0 + 2 * L1 + 2 * L2 + L3) / 6;
def FIR = (price + 2 * price[1] + 2 * price[2] + price[3]) / 6;

plot Plot1 = FIlt;
plot Plot2 = FIR;


Plot1.AssignValueColor(if Filt > FIlt[1] then Color.GREEN else Color.RED);

Plot2.AssignValueColor(if FIR  > FIlt and FIR > FIR[1]  then Color.GREEN else if FIR < FIlt and FIR < FIR[1] then Color.RED else Color.WHITE);

#Laguerre 2

input price2 = close;
input gamma2 = 0.2;

rec L00 = (1 - gamma2) * price2 + gamma2 * L00[1];
rec L11 = -gamma2 * L00 + L00[1] + gamma2 * L11[1];
rec L22 = -gamma2 * L11 + L11[1] + gamma2 * L22[1];
rec L33 = -gamma2 * L22 + L22[1] + gamma2 * L33[1];
def FIlt2 = (L00 + 2 * L11 + 2 * L22 + L33) / 6;
def FIR2 = (price2 + 2 * price2[1] + 2 * price2[2] + price2[3]) / 6;

plot Plot3 = FIlt2;
plot Plot4 = FIR2;


Plot3.AssignValueColor(if Filt2 > FIlt2[1] then Color.GREEN else Color.RED);

Plot4.AssignValueColor(if FIR2  > FIlt2 and FIR2 > FIR2[1]  then Color.GREEN else if FIR2 < FIlt2 and FIR2 < FIR2[1] then Color.RED else Color.WHITE);
That's ok for testing purposes.
 

soary

Member
Added this script to my chart but nothing shows up but it is the weekend. Does it only show up during market hours? Thanks
 
T

Thomas

Guest
I didn't want redundancy as mentione in this tread so tried to get this code but TOS says this URL appears to be broken please check and try again
The code works,...copy/paste,...if it doesn't work, scratch last letter....
 

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.
Top