Martin Pring's SPECIAL K For ThinkOrSwim

mashume

Expert
VIP
Lifetime

Martin Pring's SPECIAL K

I found this while surfing around for some longer trend indicators the other day and thought I'd code it up and see what it looked like. I hadn't seen it for ToS anywhere previously.

It looks interesting. May be useful for some who use it long term. Also looks an interesting chart for intraday tick charts if you want to determine possible changes in the overall trend of the day... Let me know if / how you find it useful and why or why not. :)

This version is adapted from pseudo code here: https://school.stockcharts.com/doku.php?st=pring special k&id=technical_indicators:pring_s_special_k ad I make no claim of ownership to either the original code nor this interpretation of it.

LINK

http://tos.mx/oTIc7uk

Eye Candy

fYbkmCR.png

5 year daily


9DNm42Q.png

1 day 250 tick

The Code

Code:
# Martin Pring's SPECIAL K
#
# as coded for ThinkOrSwim
#
# by mashume for useThinkScript.com
#
# from pseudo code here: https://school.stockcharts.com/doku.php?st=pring%20special%20k&id=technical_indicators:pring_s_special_k
#
# 2021-12-16


declare lower;

input k_ma_length = 100;

script ROC {
input n = 10;
plot ROC = ((Close - Close[n]) / (Close[n])) * 100;
}

plot Special_K =  SimpleMovingAvg(price = ROC(10), length = 10) * 1
           + SimpleMovingAvg(price = ROC(15), length = 10) * 2
           + SimpleMovingAvg(price = ROC(20), length = 10) * 3
           + SimpleMovingAvg(price = ROC(30), length = 15) * 4
           + SimpleMovingAvg(price = ROC(40), length = 50) * 1
           + SimpleMovingAvg(price = ROC(65), length = 65) * 2
           + SimpleMovingAvg(price = ROC(75), length = 75) * 3
           + SimpleMovingAvg(price = ROC(100), length = 100) * 4
           + SimpleMovingAvg(price = ROC(195), length = 130) * 1
           + SimpleMovingAvg(price = ROC(265), length = 130) * 2
           + SimpleMovingAvg(price = ROC(390), length = 130) * 3
           + SimpleMovingAvg(price = ROC(530), length = 195) * 4;

plot K_MA = SimpleMovingAvg(price = Special_K, length = k_ma_length);

plot zero = 0;

Special_K.SetDefaultColor(Color.BLUE);
K_MA.SetDefaultColor(Color.RED);
zero.SetDefaultColor(Color.GRAY);

Happy Trading
-mashume
 

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

Added Clouds, Arrows and paintbars
Code:
# Martin Pring's SPECIAL K
#
# as coded for ThinkOrSwim
#
# by mashume for useThinkScript.com
#
# from pseudo code here: https://school.stockcharts.com/doku.php?st=pring%20special%20k&id=technical_indicators:pring_s_special_k
#
# 2021-12-16
#Henry Kaczmarczyk added Arrows, Clouds, And Paintbars  removed the zero plot 2021-12-17


declare lower;

input k_ma_length = 100;

script ROC {
input n = 10;

plot ROC = ((Close - Close[n]) / (Close[n])) * 100;
}

plot Special_K = ( SimpleMovingAvg(price = ROC(10), length = 10) * 1
           + SimpleMovingAvg(price = ROC(15), length = 10) * 2
           + SimpleMovingAvg(price = ROC(20), length = 10) * 3
           + SimpleMovingAvg(price = ROC(30), length = 15) * 4
           + SimpleMovingAvg(price = ROC(40), length = 50) * 1
           + SimpleMovingAvg(price = ROC(65), length = 65) * 2
           + SimpleMovingAvg(price = ROC(75), length = 75) * 3
           + SimpleMovingAvg(price = ROC(100), length = 100) * 4
           + SimpleMovingAvg(price = ROC(195), length = 130) * 1
           + SimpleMovingAvg(price = ROC(265), length = 130) * 2
           + SimpleMovingAvg(price = ROC(390), length = 130) * 3
           + SimpleMovingAvg(price = ROC(530), length = 195) * 4)/30;

plot K_MA = SimpleMovingAvg(price = Special_K, length = k_ma_length);

Special_K.SetDefaultColor(Color.BLUE);
K_MA.SetDefaultColor(Color.RED);

Addcloud(Special_K,K_MA,Color.Blue,Color.Red);
input paintbars = 1;
input arrows = 0;
Input Dotsize = 3;

AssignPriceColor(if paintbars == 1 and Special_K > K_MA then Color.Blue else if paintbars == 1 and Special_K < K_MA then Color.Red else Color.Current);

#ARROWS
plot ArrowDown = if arrows >0  and (Special_K Crosses below K_MA) then K_MA else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Red);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if arrows >0 and (Special_K crosses above K_MA) then K_MA else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Blue);
ArrowUp.setLineWeight(dotsize);
 
Here is a version Plotted as a Histogram
Code:
# Martin Pring's SPECIAL K
#
# as coded for ThinkOrSwim
#
# by mashume for useThinkScript.com
#
# from pseudo code here: https://school.stockcharts.com/doku.php?st=pring%20special%20k&id=technical_indicators:pring_s_special_k
#
# 2021-12-16
# Changed to plot asDollars a Histogran by Henry Z Kaczmarczyk 2021-12-17


declare lower;

input k_ma_length = 100;

script ROC {
input n = 10;

plot ROC = ((Close - Close[n]) / (Close[n])) * 100;
}

Def Special_K = ( SimpleMovingAvg(price = ROC(10), length = 10) * 1
           + SimpleMovingAvg(price = ROC(15), length = 10) * 2
           + SimpleMovingAvg(price = ROC(20), length = 10) * 3
           + SimpleMovingAvg(price = ROC(30), length = 15) * 4
           + SimpleMovingAvg(price = ROC(40), length = 50) * 1
           + SimpleMovingAvg(price = ROC(65), length = 65) * 2
           + SimpleMovingAvg(price = ROC(75), length = 75) * 3
           + SimpleMovingAvg(price = ROC(100), length = 100) * 4
           + SimpleMovingAvg(price = ROC(195), length = 130) * 1
           + SimpleMovingAvg(price = ROC(265), length = 130) * 2
           + SimpleMovingAvg(price = ROC(390), length = 130) * 3
           + SimpleMovingAvg(price = ROC(530), length = 195) * 4)/3;

Def K_MA = SimpleMovingAvg(price = Special_K, length = k_ma_length);
Def OST = Special_K – K_MA;
Plot POST = OST;
POST.SetPaintingStrategy(PaintingStrategy.Line);
POST.SetLineWeight(2);
POST.assignValueColor(if POST>=POST[1] then Color.Cyan else Color.Magenta);

Input APC = 0;
Input Arrows = no;
Input Dotsize = 2;

plot ArrowDown = if arrows and (POST Crosses below POST[1]) then Post else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Magenta);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if arrows and (Post crosses above Post[1] ) then POST else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Cyan);
ArrowUp.setLineWeight(dotsize);
Def Signal = Average(OST,2);
Plot PSignal = Signal;
PSignal.SetPaintingStrategy(PaintingStrategy.Line);
PSignal.SetLineWeight(2);
PSignal.AssignValueColor(if PSignal>=PSignal[1] then Color.Cyan else Color.Magenta);
AddCloud(POST,PSignal,Color.Cyan,Color.Magenta);
Def MaxX = Max(OST,Signal);
Def MinX = Min(OST,Signal);

Def Con1 = OST >= 0;
Def Con2 = OST < 0;
Def Con3 = OST > OST[1];
Def Con4 = OST < OST[1];

Plot BullRise = If Con1 and Con3 then MinX else 0;
BullRise.SetPaintingStrategy(PaintingStrategy.Histogram);
BullRise.SetDefaultColor(Color.Green);
BullRise.SetLineWeight(3);
Plot BullFall = if Con1 and Con4 then MinX else 0;
BullFall.SetPaintingStrategy(PaintingStrategy.Histogram);
BullFall.SetDefaultColor(Color.Dark_Green);
BullFall.SetLineWeight(3);
Plot BearFall = if Con2 and Con4 then MaxX else 0;
BearFall.SetPaintingStrategy(PaintingStrategy.Histogram);
BearFall.SetDefaultColor(Color.Dark_Red);
BearFall.SetLineWeight(3);
Plot BearRise = if Con2 and Con3 then MaxX else 0;
BearRise.SetPaintingStrategy(PaintingStrategy.Histogram);
BearRise.SetDefaultColor(Color.Red);
BEarRise.SetLineWeight(3);

##APC = 1 Bar Colors are for Histogram, APC =2 Bar Colors are for POST
AssignPriceColor(if APC ==1 and Con1 and Con3 then Color.Green else if APC ==1 and Con1 and Con4 then Color.Dark_Green else if APC ==1 and Con2 and Con4 then Color.Dark_Red else if APC ==1 and Con2 and Con3 then Color.Red else if APC == 2 and Post >= Post[1] then Color.Cyan else if APC ==2 and Post < Post[1] then Color.Magenta else Color.Current);

Plot UZ = Average(OST,34) + (1.3185*StDev(OST,34));
UZ.SetPaintingStrategy(PaintingStrategy.Line);
UZ.SetLineWeight(2);
UZ.SetDefaultColor(Color.Violet);
Plot LZ = Average(OST,34) - (1.3185*StDev(OST,34));
LZ.SetPaintingStrategy(PaintingStrategy.Line);
LZ.SetLineWeight(2);
LZ.SetDefaultColor(Color.Violet);
Plot OB = 47.5;
OB.SetPaintingStrategy(PaintingStrategy.Dashes);
OB.SetDefaultColor(Color.yellow);
Plot OS = -47.5;
OS.SetPaintingStrategy(PaintingStrategy.Dashes);
OS.SetDefaultColor(Color.yellow);
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
289 Online
Create Post

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