Stochastic Normalization For ThinkOrSwim

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
# Stochastic Normalization
# Underlying & Secondary Symbol Normalized in Stochastic Range

HcHjwvU.png

Ruby:
# Stochastic Normalization
# Underlying & Secondary Symbol Normalized in Stochastic Range
# Mobius
# 11.27.2017

declare lower;

input Debug = YES;
input secondSym = "PUT";
input over_bought = .8;
input over_sold = .2;
input KPeriod = 55;
input DPeriod = 55;
input slowing_period = 3;
input averageType = AverageType.SIMPLE;

def h = if !IsNaN(high) then high else h[1];
def l = if !IsNaN(low) then low else l[1];
def c = if !IsNaN(close) then close else c[1];
def hSS = If !IsNaN(High(secondSym)) then High(secondSym) else hSS[1];
addLabel(Debug, "Second H = " + hSS);
def lSS = if !IsNaN(low(secondSym)) then low(secondSym) else lSS[1];
addLabel(Debug, "Second L = " + lSS);
def cSS = if !IsNaN(close(secondSym)) then close(secondSym) else cSS[1];
addLabel(Debug, "Second C = " + cSS);
def lowest_k = Lowest(l, KPeriod);
def lowest_ks = Lowest(lSS, KPeriod);
def c1 = c - lowest_k;
def c1s = cSS - lowest_ks;
def c2 = Highest(h, KPeriod) - lowest_k;
def c2s = Highest(hSS, KPeriod) - lowest_ks;
def FastK = if c2 != 0 then c1 / c2 else 0;
def FastKs = if c2s != 0 then c1s / c2s else 0;

plot FullK = if !IsNaN(Close[-1])
then MovingAverage(averageType, FastK, slowing_period) else Double.NaN;
plot FullKs = if !IsNaN(Close[-1])
then MovingAverage(averageType, FastKs, slowing_period) else Double.NaN;
plot OverBought = over_bought;
plot OverSold = over_sold;

FullK.SetDefaultColor(GetColor(5));
FullKs.SetDefaultColor(GetColor(1));
OverBought.SetDefaultColor(GetColor(9));
OverSold.SetDefaultColor(GetColor(9));
AddLabel(1, "This color line is " + getSymbol(), GetColor(5));
AddLabel(1, "This color line is " + secondSym, GetColor(1));

#######################################################################
input ShowArrows = YES;

plot ArrDn = if ShowArrows and FullKs crosses above OverSold then OverBought else Double.NaN;
ArrDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

plot ArrUp = if ShowArrows and FullKs crosses below OverBought then OverSold else Double.NaN;
ArrUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);




# End Code Stochastic Normalization
 

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

I was wondering if someone can help with adding alerts to when the arrows come up in this indicator please? I have no idea how to code and would very much like this done. Thank you.

Does this one have the alerts?
 
Last edited by a moderator:
I was wondering if someone can help with adding alerts to when the arrows come up in this indicator please? I have no idea how to code and would very much like this done. Thank you.

Does this one have the alerts?

Add something like this to the bottom of the study:
input audibleAlerts = yes;
Alert(audibleAlerts and FullKs crosses below OverBought, "Alert 1", Alert.BAR, Sound.Ding);
Alert(audibleAlerts and FullKs crosses above OverSold, "Alert 2", Alert.BAR, Sound.Ring);
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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