Jurik Moving Average ?

Hey everyone! I've recently learned about the Jurik MA and its use within the institutional world. Wondering if anyone has used it and their experiences/thoughts with it.
The formula seems to be a secret but some have tried to decode it. Here is a few good blogs in attempt to define/reveal calculations.
https://c.mql5.com/forextsd/forum/164/jurik_1.pdf
https://regtrading.com/the-real-jurik-moving-average-jma/

Everget on TradingView has attempted a variation which I tried to convert it to TOS (below) but it's plotting displaced lower on chart. Any help would be appreciated.
https://www.tradingview.com/v/nZuBWW9j/

input length = 7;
input phase = 50;
input power = 2;
input src = close;
#input highlightMovements = YES;
script nz {
input data = 0;
def ret_val = if IsNaN(data) then 0 else data;
plot return = ret_val;
}

def phaseRatio = if phase < -100 then 0.5
else if phase > 100 then 2.5
else phase / 100 + 1.5;

def beta = 0.45 * (length - 1) / (0.45 * (length - 1) + 2);
def alpha = Power(beta, power);

def jma = 0.0;
def e0 = (1 - alpha) * src + alpha * nz(e0[1]);
def e1 = (src - e0) * (1 - beta) + beta * nz(e1[1]);
def e2 = (e0 + phaseRatio * e1 - nz(jma[1])) * Power(1 - alpha, 2) + Power(alpha, 2) * nz(e2[1]);
def e3 = e2 + nz(jma[1]); ## this is supposed to be a reassignment of value
plot jmaPlot = e3;


jmaPlot.DefineColor("Up", GetColor(1));
jmaPlot.DefineColor("Down", GetColor(0));
jmaPlot.AssignValueColor(if jmaPlot > jmaPlot[1] then jmaPlot.Color("Up") else jmaPlot.Color("Down"));
 
Last edited:
Hey everyone! I've recently learned about the Jurik MA and its use within the institutional world. Wondering if anyone has used it and their experiences/thoughts with it.
The formula seems to be a secret but some have tried to decode it. Here is a few good blogs in attempt to define/reveal calculations.
https://c.mql5.com/forextsd/forum/164/jurik_1.pdf
https://regtrading.com/the-real-jurik-moving-average-jma/

Everget on TradingView has attempted a variation which I tried to convert it to TOS (below) but it's plotting displaced lower on chart. Any help would be appreciated.
https://www.tradingview.com/v/nZuBWW9j/

input length = 7;
input phase = 50;
input power = 2;
input src = close;
#input highlightMovements = YES;
script nz {
input data = 0;
def ret_val = if IsNaN(data) then 0 else data;
plot return = ret_val;
}

def phaseRatio = if phase < -100 then 0.5
else if phase > 100 then 2.5
else phase / 100 + 1.5;

def beta = 0.45 * (length - 1) / (0.45 * (length - 1) + 2);
def alpha = Power(beta, power);

def jma = 0.0;
def e0 = (1 - alpha) * src + alpha * nz(e0[1]);
def e1 = (src - e0) * (1 - beta) + beta * nz(e1[1]);
def e2 = (e0 + phaseRatio * e1 - nz(jma[1])) * Power(1 - alpha, 2) + Power(alpha, 2) * nz(e2[1]);
def e3 = e2 + nz(jma[1]); ## this is supposed to be a reassignment of value
plot jmaPlot = e3;


jmaPlot.DefineColor("Up", GetColor(1));
jmaPlot.DefineColor("Down", GetColor(0));
jmaPlot.AssignValueColor(if jmaPlot > jmaPlot[1] then jmaPlot.Color("Up") else jmaPlot.Color("Down"));
I read on the thinkscript lounge that Jurik Moving Average is a two pole gaussian filter applied to price. Below is code for a two pole gaussian filter that I took from the following paper by Ehlers. It's very close to the jma on tradingview.

https://www.mesasoftware.com/papers/GaussianFilters.pdf

Code:
# Two Pole Gaussian Filter (Jurik Moving Average?)
# by bigboss

input length = 7;
input n = 2.0;
input source = close;
input highlight_movements = yes;

def c = source;
def w = (2 * Double.Pi / length);
def beta = (1 - Cos(w)) / (Power(1.414, 2.0 / n) - 1 );
def alpha = (-beta + Sqrt(beta * beta + 2 * beta));
def g =  power(alpha,2)*c + 2*(1-alpha)*g[1] - power(1-alpha,2) * g[2];

plot jma = g;

jma.assignValueColor(if !highlight_movements then color.current else if jma > jma[1] then color.green else color.red);
jma.setlineWeight(2);
 

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

Here's another with more bells and whistles.

Code:
# John Ehlers Gaussian AV

# Author: Mcdon030

# Date: 20201107

#https://www.mesasoftware.com/papers/GaussianFilters.pdf

## NOTE:

# 1.  Added a few additional poles

# 2. Scaled price

# 3.  Added Mobius Thinkscript lounge price prediction

# 4.  Higher Aggregation selection

script JEGauss {

input value= close;

input period = 20;

input numpoles = 4;

def beta = (1 - cos(2 * Double.Pi/(period))) / (Power(2, 1.0 / numPoles) - 1);

def alpha = (-beta + Sqrt(power(beta,2)  + 2 * beta));

def filt;

if (numpoles==1){

filt= alpha*value + (1 - alpha) * filt[1];

} else if numPoles==2 {

filt =Power(alpha, 2)*value +2*(1-alpha)*filt[1]-Power(1-alpha, 2)*filt[2];

} else if numPoles==3 {

filt=Power(alpha,3)*value+3*(1-alpha)*filt[1]-3*Power(1-alpha, 2)*filt[2] +Power(1-alpha, 3)*filt[3] ;

} else if numPoles==4{

filt =Power(alpha,4)*value+4 *(1-alpha)*filt[1]-6*Power(1-alpha,2)*filt[2]+4*Power(1-alpha,3)*filt[3]-Power(1-alpha,4)*filt[4];

 }else if numPoles==5 {

filt =Power(alpha,5)*value+5*(1-alpha)*filt[1]-10*Power(1-alpha,2)*filt[2]+10*Power(1-alpha,3)

*filt[3]-5*Power(1-alpha,4)*filt[4]+Power(1 - alpha, 5) * filt[5];

        } else if numPoles==6{

filt =Power(alpha,6)*value+6*(1-alpha)*filt[1]-15*Power(1-alpha,2)*filt[2]+20*Power(1-alpha,3)

*filt[3]-15*Power(1-alpha,4)*filt[4]+6*Power(1 - alpha, 5) * filt[5]-Power(1 - alpha, 6) * filt[6];

        } else {

filt =Power(alpha,7)*value+7*(1-alpha)*filt[1]-21*Power(1-alpha,2)*filt[2]+35*Power(1-alpha,3)

*filt[3]-35*Power(1-alpha,4)*filt[4]+21*Power(1 - alpha, 5) * filt[5]-7*Power(1 - alpha, 6) * filt[6]+Power(1 - alpha, 7) * filt[7];

        }

 plot isfilt = filt;

}

# End ehlers gaussian filter

 

input period =15;

input pricecolor =yes;

 

def numpoles;

 input choose = {one,two,  default  three, four,five,six,seven};

 switch (choose ) {

case one:

   numpoles=1;

case two:

   numpoles=2;

case three:

   numpoles=3;

case four:

   numpoles=4;

case five:

   numpoles=5;

case six:

   numpoles=6;

case seven:

   numpoles=7;

}

input HighAG = aggregationPeriod.Fifteen_Min;

input Timeframe= {default  normal, higher}; 

def c;

switch (Timeframe){

case normal:

        c = JEGauss(close,period,numPoles);

case higher:

        c = JEGauss(close(period=Highag)[1],period,numPoles);

}

## remove lag     page 4

def f1 = .10*c+.80*c[1]+.10*c[2];

def f2 = (c + 2 * c[1] + 2 * c[2] + c[3]) / 6;

 

 

 

input ScalePrice = Yes;

def tickS = if !IsNaN(TickSize()) then TickSize() else .01;

def Pricescale = if ScalePrice then c *tickS/tickS else c;

 

 

 

## mobius prie predicton posts thinkscript lounge

input ShowMobiusPrediction = yes;

input nx = 10;

def mx = fold mi = 0 to nx

        with s

        do s + getValue(sum(Pricescale[1] / (Pricescale[3] /Pricescale[2]), nx)/nx, mi) / nx;

def statex;

 if (crosses(Pricescale,mx ,crossingDirection.ABOVE)) {

      statex = 100;

} else if  (crosses(Pricescale,mx ,crossingDirection.below)) {

     statex = -100;

}  else {

     statex = statex[1];

}

### plots

plot Jgauss=Pricescale;

Jgauss.AssignValueColor(if  statex ==100 then Color.Cyan else Color.Magenta);

Jgauss.SetLineWeight(1);

plot JgaussPred = if ShowMobiusPrediction then  mx else double.nan;

JgaussPred.AssignValueColor(if  statex ==100 then Color.light_green else Color.light_RED);

JgaussPred.SetLineWeight(2);

JgaussPred.HideBubble();

JgaussPred.HideTitle();

AssignPriceColor(if pricecolor  then

    if statex==100 then Color.GREEN

                else if statex==-100  then Color.RED

                else Color.GRAY else  Color.CURRENT );

addlabel(1, "Mcdon030 -> John Ehlers Gaussian AV:", color.orange);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
488 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