Laguerre Used for Stop Placement

ebtrader

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:
D

diazlaz

Well-known member
2019 Donor
VIP
thanks for sharing @ebtrader seems has potential! - Applicable across all time frames. Nice work and thanks again!
 
ebtrader

ebtrader

New member
thanks for sharing @ebtrader seems has potential! - Applicable across all time frames. Nice work and thanks again!
i love studies that work across all time frames like this one. i you have any tweaks to it, please let me know.
 
markos

markos

Well-known member
VIP
@ebtrader just curious, why do you have Gamma at 0.2 vs 0.5 or higher?
 
ebtrader

ebtrader

New member
@ebtrader just curious, why do you have Gamma at 0.2 vs 0.5 or higher?
it has been ages since i tweaked it, but i guess that's the setting that helped me get what i wanted. Is 0.5 the standard out there?
 
markos

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

ebtrader

New member
I just tried 0.5 and it is really neat - shows the turns sooner, but not confirmed until crosses over - so basically shows the countertrend trades until the crossover.

 
ebtrader

ebtrader

New member
It might be best to have both 0.5 and 0.2 on the same chart to keep you in the trade.
 
ebtrader

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

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

chillc15

New member
it has been ages since i tweaked it, but i guess that's the setting that helped me get what i wanted. Is 0.5 the standard out there?
ebtrader curious if you used any other complimentary indicator with this that was not redundant. Thanks
 
S

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

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