Stochastic Watchlist, Scan, Alert, Arrows & Other For ThinkOrSwim

This allows an input option to show crossover arrows.

So I was given the stochastic Momentum Index with buy and sell arrows at the crossovers. But the study shows in the lower section and not for the upper chart windows. I would like the crossover buy and crossover sell arrows from the StochasticMomentumIndex show in the upper chart with the candle sticks so I do not have to look at the lower study. Can someone help me with this please. I hope I explained it well.

Below is what I was given. I am looking to get those arrows into the candle stick chart chart upper area..not the lower study area. And to show the arrows exactly as it hits the crossover..not after it passes. Thank you so much.

#
# TD Ameritrade IP Company, Inc. (c) 2008-2022
#

declare lower;

input crossover_arrows = yes;
input over_bought = 40.0;
input over_sold = -40.0;
input percentDLength = 3;
input percentKLength = 5;

def min_low = Lowest(low, percentKLength);
def max_high = Highest(high, percentKLength);
def rel_diff = close - (max_high + min_low) / 2;
def diff = max_high - min_low;

def avgrel = ExpAverage(ExpAverage(rel_diff, percentDLength), percentDLength);
def avgdiff = ExpAverage(ExpAverage(diff, percentDLength), percentDLength);

plot SMI = if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0;
SMI.SetDefaultColor(GetColor(1));

plot AvgSMI = ExpAverage(SMI, percentDLength);
AvgSMI.SetDefaultColor(GetColor(5));

plot overbought = over_bought;
overbought.SetDefaultColor(GetColor(5));

plot oversold = over_sold;
oversold.SetDefaultColor(GetColor(5));

#Arrows
plot uparrow = if !crossover_arrows then Double.NaN
else if SMI crosses above AvgSMI
then SMI
else Double.NaN;
uparrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
uparrow.SetLineWeight(3);
uparrow.SetDefaultColor(GetColor(1));

plot dnarrow = if !crossover_arrows then Double.NaN
else if SMI crosses below AvgSMI
then SMI
else Double.NaN;
dnarrow.SetPaintingStrategy(PaintingStrategy.ARROW_DoWN);
dnarrow.SetLineWeight(3);
dnarrow.SetDefaultColor(GetColor(5));
 
Last edited by a moderator:

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

So I was given the stochastic Momentum Index with buy and sell arrows at the crossovers. But the study shows in the lower section and not for the upper chart windows. I would like the crossover buy and crossover sell arrows from the StochasticMomentumIndex show in the upper chart with the candle sticks so I do not have to look at the lower study. Can someone help me with this please. I hope I explained it well.

Below is what I was given. I am looking to get those arrows into the candle stick chart chart upper area..not the lower study area. And to show the arrows exactly as it hits the crossover..not after it passes. Thank you so much.

#
# TD Ameritrade IP Company, Inc. (c) 2008-2022
#

declare lower;

input crossover_arrows = yes;
input over_bought = 40.0;
input over_sold = -40.0;
input percentDLength = 3;
input percentKLength = 5;

def min_low = Lowest(low, percentKLength);
def max_high = Highest(high, percentKLength);
def rel_diff = close - (max_high + min_low) / 2;
def diff = max_high - min_low;

def avgrel = ExpAverage(ExpAverage(rel_diff, percentDLength), percentDLength);
def avgdiff = ExpAverage(ExpAverage(diff, percentDLength), percentDLength);

plot SMI = if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0;
SMI.SetDefaultColor(GetColor(1));

plot AvgSMI = ExpAverage(SMI, percentDLength);
AvgSMI.SetDefaultColor(GetColor(5));

plot overbought = over_bought;
overbought.SetDefaultColor(GetColor(5));

plot oversold = over_sold;
oversold.SetDefaultColor(GetColor(5));

#Arrows
plot uparrow = if !crossover_arrows then Double.NaN
else if SMI crosses above AvgSMI
then SMI
else Double.NaN;
uparrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
uparrow.SetLineWeight(3);
uparrow.SetDefaultColor(GetColor(1));

plot dnarrow = if !crossover_arrows then Double.NaN
else if SMI crosses below AvgSMI
then SMI
else Double.NaN;
dnarrow.SetPaintingStrategy(PaintingStrategy.ARROW_DoWN);
dnarrow.SetLineWeight(3);
dnarrow.SetDefaultColor(GetColor(5));
ToS SMI Crossover made into an upper chart
DBIdJdQ.png

Ruby:
# ToS SMI Crossover
# made into an upper chart
# @merryday 10/22
#
input crossover_arrows = yes;
input over_bought = 40.0;
input over_sold = -40.0;
input percentDLength = 3;
input percentKLength = 5;

def min_low = Lowest(low, percentKLength);
def max_high = Highest(high, percentKLength);
def rel_diff = close - (max_high + min_low) / 2;
def diff = max_high - min_low;

def avgrel = ExpAverage(ExpAverage(rel_diff, percentDLength), percentDLength);
def avgdiff = ExpAverage(ExpAverage(diff, percentDLength), percentDLength);

def SMI = if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0;
def AvgSMI = ExpAverage(SMI, percentDLength);
# Charting and Formatting

#Arrows
plot uparrow = if !crossover_arrows then Double.NaN
else if SMI crosses above AvgSMI
then low
else Double.NaN;
uparrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
uparrow.SetLineWeight(3);
uparrow.SetDefaultColor(GetColor(1));

plot dnarrow = if !crossover_arrows then Double.NaN
else if SMI crosses below AvgSMI
then high
else Double.NaN;
dnarrow.SetPaintingStrategy(PaintingStrategy.ARROW_DoWN);
dnarrow.SetLineWeight(3);
dnarrow.SetDefaultColor(GetColor(5));
 
Last edited:
How to get alert on Stochastic cross over and under 75 and 35.
Thank you in advance.
https://photos.app.goo.gl/hW58Vdwv4CfKyz7J8
Ruby:
plot stoch = reference StochasticFull(75, 35, 14, 3, high, low, close, 3, AverageType.SIMPLE);
     stoch.hide();

Alert(stoch crosses 75, "stoch crosses 75", Alert.Bar, Sound.Bell);
Alert(stoch crosses 35, "stoch crosses 35", Alert.Bar, Sound.Bell);

https://usethinkscript.com/resources/how-to-add-alert-script-to-thinkorswim-indicators.9/
 
Last edited:
Hi- I need help to " Assign Background Color " for a Stochastic Slow Indicator above 80 and below 20.
My incorrect attempt :
assignbackgroundcolor ( if SlowK > overbought then color.green else if SlowK < oversold then color.red else color.gray);

I would appreciate help on how to write this the proper way. Thank You !
 
Hi- I need help to " Assign Background Color " for a Stochastic Slow Indicator above 80 and below 20.
My incorrect attempt :
assignbackgroundcolor ( if SlowK > overbought then color.green else if SlowK < oversold then color.red else color.gray);

I would appreciate help on how to write this the proper way. Thank You !

Given that your syntax is correct; the problem must be with your definitions. When submitting posts to the forum, it is always best to provide the complete script.

1l95H8x.png

Most members do not color the backgrounds of their charts as it can be jarring.
So you might want to use the included labels instead.
SlowK Label Colors
bv7dg41.png


Below is a complete script.
Ruby:
#slowK paint background OB vs OS

input overbought = 80 ;
input oversold = 20 ;
def slowK = StochasticSlow();

input paint = yes ;
assignbackgroundcolor(
if !paint then color.current else
if paint and SlowK > overbought then color.dark_green else
if paint and SlowK < oversold then color.dark_red else color.current);

# ########################################################
#upper chart: slowK label
#Using GlobalColors makes the colors modifiable
DefineGlobalColor("maxxed", CreateColor(50, 200, 255)) ;
DefineGlobalColor("rising",  CreateColor(0, 165, 0)) ;
DefineGlobalColor("bear",  CreateColor(225, 0, 0)) ;
DefineGlobalColor("bottom", color.orange) ;

input show_label = yes ;
AddLabel(show_label,
         if slowK > overbought then "slowK is maxxed" else
         if slowK < oversold then "slowK is bottoming" else
         if slowK > slowK [1] then "slowK is trending " +round(slowK ,1)
              else "slowK is Bear " +round(slowK ,1),
if slowK > overbought then GlobalColor("maxxed") else
if slowK < oversold then GlobalColor("bottom") else
if slowK > slowK [1] then GlobalColor("rising")
     else GlobalColor("bear"));

# ########################################################
 
Last edited:
Thanks Merry Day for your script. Identifying the area between overbought and oversold is what i couldn't figure out . eg:
if slowK > overbought then "slowK is maxxed" else
if slowK < oversold then "slowK is bottoming" else
if slowK > slowK [1] then "slowK is trending " +round(slowK ,1)
else "slowK is Bear " +round(slowK ,1),

Thanks again for your help :)
 
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
427 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