NexusFi: Find Your Edge


Home Menu

 





Help With EasyLanguage Notation of John Ehlers 4 Pole Gaussian Filter


Discussion in ThinkOrSwim

Updated
    1. trending_up 4,425 views
    2. thumb_up 4 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread

Help With EasyLanguage Notation of John Ehlers 4 Pole Gaussian Filter

  #1 (permalink)
cameroon
New York, New York
 
Posts: 1 since Mar 2012
Thanks Given: 0
Thanks Received: 0

Here's the EasyLanguage code for John Ehlers' 4 Pole Gaussian Filter:

Four Poles: f = alpha^4g + 4(1-alpha)f[1] - 6(1-alpha)^2f[2] + 4(1-alpha)^3f[3] - (1-alpha)^4f[4]
g=price and where alpha = =-Beta+SQR(Beta^2 +2*Beta), and Where Beta = (1 – cos(symbol)) / (1.414^2/N – 1), where symbol = 2pi/P, N = # of poles in the filter, in this case 4, and P = Period, i.e 15

Here's what I came up with: (I just solved what 2pi b/c I don't know the function to use for pi, and I solved what 1.414^(2/N); N=4(4 Pole), so equals 1.18911732 minus 1 from the EasyLanguage formula above. The problem I'm experiencing is that I get a legit plot for 15 period, but once I adjust the plot, i.e move to 20 period, it goes insane, rendering it useless for higher than 20 period. Reason? Any suggestion would be awesome.

input period = 15;
input paintbars = {"Yes", default "No"};
def price = vwap;
def symbol = (6.28318531) / period;
def beta = (1 – Cos(symbol)) / (0.18911732);

def alpha = -beta + Sqr(power(beta,2) + (2 * beta));
rec Gaussian = (Power(alpha, 4)) * price + (4 * (1 - alpha)) * Gaussian[1] - 6 * Power(1 - alpha, 2) * Gaussian[2] + 4 * Power(1 - alpha, 3) * Gaussian[3] - Power(1 - alpha, 4) * Gaussian[4];

plot GF= Gaussian;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
Quant vue
Trading Reviews and Vendors
What broker to use for trading palladium futures
Commodities
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
  #2 (permalink)
divzero
San Francisco
 
Posts: 1 since Apr 2012
Thanks Given: 0
Thanks Received: 1

The thing to remember with EasyLanguage code is that it automatically converts degrees to radians whereas thinkscript does not. Here's a Gaussian 2-pole filter in thinkscript. Hope this helps.


declare upper;
input period = 9;

script DegToRad {
input degrees = 0.0;
plot DegToRad = degrees * Double.Pi / 180;
};

def beta1 = 2.415 * (1 - Cos(DegToRad(360.0 / period)));
def alpha = -beta1 + Sqrt(beta1 * beta1 + 2 * beta1);

def mCoef1 = alpha * alpha;
def mCoef2 = 2 * (1 - alpha);
def mCoef3 = -(1 - alpha) * (1 - alpha);

rec mFilterSeries = mCoef1 * hl2 + mCoef2 * mFilterSeries[1] + mCoef3 * mFilterSeries[2];

plot GaussianFilter = if IsNaN(close[2*period]) then Double.NaN else mFilterSeries;

GaussianFilter.SetDefaultColor(Color.yellow);

Reply With Quote




Last Updated on May 16, 2012


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts