Jurik Moving Average Crossover For ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
Would love to see this make it to the ToS tool box, feel like it could give the McGinley ribbon a run for its money if anyone feels like converting it for the community. Appreciate anyone willing to commit to it 🙌

https://www.tradingview.com/v/pM6FkCHY/
Cb2AAaO.png


CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © ChuckBanger
#Request from https://usethinkscript.com/ memeber
#study("Jurik Moving Average Crossover Strategy [ChuckBanger]", shorttitle="JMAC CB"
# Converted by Sam4Cok@Samer800 - 09/2022
### Inputs ######
input ShowBand = yes;
input MidLineSignal = yes;
input ShowFastLine = no;
input length = 30;     # "Length"
input phase = 0;       # "Phase"
input power = 2;       # "Power"
input src = close;     # "Source"
input highlight = yes; # "Highlight Up/Down"
def atrLength = 30;    # "ATR Length"
def mult = 1.5;        # "ATR Multiplyer"
def fastLength = 5;    # "Fast Length"
def fastPhase = 100;   # "Fast Phase"
def fastPower = 2;     # "Fast Power"

def na = Double.NaN;
script nz {
    input data  = close;
    input repl  = 0;
    def ret_val = if isNaN(data) then repl else data;
    plot return = ret_val;
}
#calc_jma(_src, _length, _phase, _power) =>
script calc_jma {
input _src = close;
input _length = 0;
input _phase = 0;
input _power = 0;

    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 e0; def e1; def e2; def jma;
    e0 = (1 - alpha) * _src + alpha * nz(e0[1]); 
    e1 = (_src - e0) * (1 - beta) + beta * nz(e1[1]);
    e2 = (e0 + phaseRatio * e1 - nz(jma[1])) *
       power(1 - alpha, 2) + power(alpha, 2) * nz(e2[1]);
    jma = e2 + nz(jma[1]);
plot return = jma;
}
def jma = calc_jma(src, length, phase, power);
def jmaColor = if highlight then if jma > jma[1] then 1 else -1 else 0;
plot jmaLine = jma;
jmaLine.SetLineWeight(2);
jmaLine.AssignValueColor( if jmaColor > 0 then CreateColor(0,188,212) else
                          if jmaColor < 0 then CreateColor(136,14,79) else
                                               CreateColor(33,150,243));
def atr_ = atr(Length = atrLength);
def upper = jma + (atr_ * mult);
def lower = jma - (atr_ * mult);
plot BandUp = upper;
BandUp.SetDefaultColor(CreateColor(33,150,243));
BandUp.SetHiding(!ShowBand);
plot BandLo = lower;
BandLo.SetDefaultColor(CreateColor(33,150,243));
BandLo.SetHiding(!ShowBand);

def fastJma = calc_jma(src, fastLength, fastPhase, fastPower);

plot fastJmaLine = fastJma;
fastJmaLine.SetDefaultColor(Color.GRAY);
fastJmaLine.SetHiding(!ShowfastLine);

plot cross = if (fastJma crosses jma) then jma else na;
cross.SetPaintingStrategy(PaintingStrategy.POINTS);
cross.SetDefaultColor(Color.ORANGE);
cross.SetLineWeight(2);
cross.SetHiding(!MidLineSignal);

plot CrossDn = if (fastJma crosses below upper) then (upper + (atr_/4)) else na;# style=plot.style_circles, linewidth=5, color=color.red, title='JMA Upper crossunder', transp=0)
crossDn.SetPaintingStrategy(PaintingStrategy.POINTS);
crossDn.SetDefaultColor(Color.RED);
crossDn.SetLineWeight(5);

plot CrossUp = if (fastJma crosses above lower) then (lower - (atr_/4)) else na;
crossUp.SetPaintingStrategy(PaintingStrategy.POINTS);
crossUp.SetDefaultColor(Color.LIME);
crossUp.SetLineWeight(5);
 
Last edited:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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