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

 
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
 

Thomas

Active member
VIP
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

Top