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

Because @Slippage Provided you with a code 'snippet' You need to add the snippet to the study that you are using and you have to have FullK defined. An example would be:
Ruby:
plot FullK = reference StochasticFull().FullK ;

FullK.AssignValueColor(
  if FullK > FullK[1] then Color.GREEN
  else if FullK < FullK[1] then Color.RED
  else Color.GRAY
);
 

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

What Im trying to do here is: Signal will occur when the fullK moving average goes overbought above 80/ overbought then the fullK moving average will come down and crossover under the fullD moving average and Signal will occur when the fullK moving average goes below 20/oversold then the fullk moving average will come up and crossover above the fullD moving average. The problem I have is that Im only getting half of the signals. Thanks.

Code:
declare lower;

# Base code by TD Ameritrade IP Company, Inc. (c) 2008-2021

input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input DPeriod = 10;
input priceH = high;
input priceL = low;
input priceC = close;
input slowing_period = 3;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On FullK", "On FullD", "On FullK & FullD"};

def lowest_k = Lowest(priceL, KPeriod);
def c1 = priceC - lowest_k;
def c2 = Highest(priceH, KPeriod) - lowest_k;
def FastK = if c2 != 0 then c1 / c2 * 100 else 0;

plot FullK = MovingAverage(averageType, FastK, slowing_period);
plot FullD = MovingAverage(averageType, FullK, DPeriod);

plot OverBought = over_bought;
plot OverSold = over_sold;



# signal

def fullKCrossesFromoverbought= FullK[1] > 80 and FullK < 80;
def fullKCrossesBelowFullD = FullK[1] > FullD[1] and FullK < FullD;
plot signaldown = fullKCrossesFromoverbought and fullKCrossesBelowFullD;
signaldown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_down);
signaldown.SetDefaultColor(Color.magenta);

def fullKCrossesFromoversold = FullK[1] < 20 and FullK > 20;
def fullKCrossesAboveFullD = FullK[1] < FullD[1] and FullK > FullD;
plot signalup = fullKCrossesFromoversold and fullKCrossesAboveFullD;
signalup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
signalup.SetDefaultColor(Color.cyan);

aB6gWza.jpg
 
@analyst2345 My understanding is that you want to
  • look for a FullK that crossed oversold on some previous candle and
  • is now crossing over FullD on the current candle.
This is a rather complex cumbersome way to use the Stochastic. There are much cleaner, time-tested, Stochastics available. I know that you have been going through the Stochastics studies available, You might want to keep looking. Beside searching on Stochastic, look at some of these Stochastics: IronRod, 3x, and Savage
 
Last edited:
I was looking for the exact same scan and found this great tutorial on youtube

I ended up with this - It combines stochastic slow + macd

The scan is designed for a Weekly timeframe

Enjoy

Ruby:
# Courtesy of Hahn-Tech, LLC
# https://www.youtube.com/watch?v=VOJwH9U0aL0

# macd scan
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageTypeMACD = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;

def Value = MovingAverage(averageTypeMACD, close, fastLength) - MovingAverage(averageTypeMACD, close, slowLength);
def Avg = MovingAverage(averageTypeMACD, Value, MACDLength);
def Diff = Value - Avg;

# stochastic slow scan
input over_bought = 80;
input over_sold = 20;
input KPeriod = 14;
input DPeriod = 7;
input priceH = high;
input priceL = low;
input priceC = close;
input averageTypeStoch = AverageType.SIMPLE;
input showBreakoutSignalsStoch = {default "No", "On SlowK", "On SlowD", "On SlowK & SlowD"};

def SlowK = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,priceH,priceL,priceC,3,averageTypeStoch).FullK;
def SlowD = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,priceH,priceL,priceC,3,averageTypeStoch).FullD;;

# Establish crossover of slowd (SMA) above slowk (high/low prices period)
plot Scan = (SlowK[1] < SlowD[1]) and (SlowK > SlowD)
# Only look at slowk value under oversold value of 20
and (lowest(SlowK[1], 3) < 20)
# Macd should be rising
and (Diff[1] > Diff[2]);
How would I change this to daily.
 
Hello,

I was wondering if anyone could help make a stochastic scanner for the details provided below.

IB3eQaE.png


dhqSWJg.png


I want the %K line to be passing through the lower band length of 32 on the stochastic and preferably the %D line also passing through it. I was wondering if we could limit it to show no stocks with those lines higher than 50.

This would be on a daily time length and my settings on are all provided in the pictures above.

Thanks in advance guys!
 
Hello,

I was wondering if anyone could help make a stochastic scanner for the details provided below.

I want the %K line to be passing through the lower band length of 32 on the stochastic and preferably the %D line also passing through it. I was wondering if we could limit it to show no stocks with those lines higher than 50.

This would be on a daily time length and my settings on are all provided in the pictures above.

Thanks in advance guys!
We don't have anything like what you describe on the forum. There is a ToS Double Smoothed Stochastic is also a smoothed Stochastic as you describe but it is calculated differently. Maybe you can make it work for you.
 
Hello,
I have been following Raghee Horner from Simpler Trading and really see potential in the use of the Slow Stochastic she uses.
I am in need of some help in creating a scan that finds the green up arrow or red down arrow triggers for a specific timeframe.
The image below is a screenshot with the red down arrow on a 1 hour chart.

I did find some tutorials on creating custom scans but am not having any luck.

If anyone could offer assistance or point me in the right direction it would be much appreciated.
YLa0ciI.png
 
Last edited by a moderator:
I like the "StochasticWithSignals" indicator and was wanting help in deconstructing how it worked.

When it comes to the signals, I get how crossing the overbought and oversold lines generate signal arrows, but I am lost on what kind of event triggers the up and down arrows between the overbought and oversold zones.

I had assumed it was perhaps when a fast k crossed a slow d or vice versa, but comparing it to other Stoch indicators that show crossovers, none seem to match the middle zone signal events.

Any insights would be most welcome. Thank you.
 
I like the "StochasticWithSignals" indicator and was wanting help in deconstructing how it worked.

When it comes to the signals, I get how crossing the overbought and oversold lines generate signal arrows, but I am lost on what kind of event triggers the up and down arrows between the overbought and oversold zones.

I had assumed it was perhaps when a fast k crossed a slow d or vice versa, but comparing it to other Stoch indicators that show crossovers, none seem to match the middle zone signal events.

Any insights would be most welcome. Thank you.
ToS does not have an indicator called "StochasticWithSignals".
If referring to one of the many scripts in this thread, please provide the post# or the actual script.
 
Need some help.
im trying to create an alert for two conditions in the Slow Stoch.
I. when slow K is above 80, and then crosses below slow D - want a down arrow and an audible alert
II. when slow K is less than 20 and then crosses above slow D - want an up arrow and audible alert
(no alerts if there are crosses when K is between 80-20)

See my attempt below.
I've created "signal" which accomplishes "I." and "signal two" which accomplishes II. -- but i cant seem to get the arrows to work.
All of my attempts end up putting arrows corresponding with every single candle as opposed to just when the crossover occurs

can anyone help?

declare lower;

input over_bought = 80;
input over_sold = 20;
input KPeriod = 8;
input DPeriod = 3;
input priceH = high;
input priceL = low;
input priceC = close;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On SlowK", "On SlowD", "On SlowK & SlowD"};

plot SlowK = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,priceH,priceL,priceC,3,averageType).FullK;
plot SlowD = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,priceH,priceL,priceC,3,averageType).FullD;
plot OverBought = over_bought;
plot OverSold = over_sold;

def slowKOverbought = slowK[1] > 80;
def slowKCrossesBelowSlowD = slowK[1] > slowD[1] and slowK < slowD;
def signal = slowKOverbought and slowKCrossesBelowSlowD;
Alert(signal, "SlowK and SlowD Crossing: OverBought", Alert.BAR, Sound.RING);

def slowKOverSold = slowK[1] < 20;
def slowKCrossesAboveFullD = slowK[1] < slowD[1] and slowK > slowD;
def signaltwo = slowKOverSold and slowKCrossesAboveFullD;
Alert(signaltwo, "SlowK and SlowD Crossing: OverSold", Alert.BAR, Sound.RING);
 
Last edited by a moderator:
Need some help.
im trying to create an alert for two conditions in the Slow Stoch.
I. when slow K is above 80, and then crosses below slow D - want a down arrow and an audible alert
II. when slow K is less than 20 and then crosses above slow D - want an up arrow and audible alert
(no alerts if there are crosses when K is between 80-20)

See my attempt below.
I've created "signal" which accomplishes "I." and "signal two" which accomplishes II. -- but i cant seem to get the arrows to work.
All of my attempts end up putting arrows corresponding with every single candle as opposed to just when the crossover occurs

can anyone help?
I didn't check your logic. I just added the arrow statements.
qovtJUT.png

Ruby:
declare lower;

input over_bought = 80;
input over_sold = 20;
input KPeriod = 8;
input DPeriod = 3;
input priceH = high;
input priceL = low;
input priceC = close;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On SlowK", "On SlowD", "On SlowK & SlowD"};

plot SlowK = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,priceH,priceL,priceC,3,averageType).FullK;
plot SlowD = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,priceH,priceL,priceC,3,averageType).FullD;
plot OverBought = over_bought;
plot OverSold = over_sold;

def slowKOverbought = slowK[1] > 80;
def slowKCrossesBelowSlowD = slowK[1] > slowD[1] and slowK < slowD;
plot signal = if slowKOverbought and slowKCrossesBelowSlowD then SlowK else double.NaN;
     signal.SetPaintingStrategy(PaintingStrategy.ARROW_down);
     signal.SetDefaultColor(color.magenta) ;
     signal.SetLineWeight(1);

Alert(signal, "SlowK and SlowD Crossing: OverBought", Alert.BAR, Sound.RING);

def slowKOverSold = slowK[1] < 20;
def slowKCrossesAboveFullD = slowK[1] < slowD[1] and slowK > slowD;
plot signaltwo = if slowKOverSold and slowKCrossesAboveFullD then SlowK else double.NaN;;
     signaltwo.SetPaintingStrategy(PaintingStrategy.ARROW_up);
     signaltwo.SetDefaultColor(color.blue) ;
     signaltwo.SetLineWeight(1);

Alert(signaltwo, "SlowK and SlowD Crossing: OverSold", Alert.BAR, Sound.RING);
 
Hello, can someone be able to make me a stochastic slow D and Slow K cross overs for the upper chart. So I would see an arrow on the candle to the upside or downside when they cross each other.
 
Last edited by a moderator:
Hello, can someone be able to make me a stochastic slow D and Slow K cross overs for the upper chart. So I would see an arrow on the candle to the upside or downside when they cross each other.
# SlowK Crossing SlowD Stochastic Arrows Upper Chart
Ruby:
# SlowK Crossing SlowD Stochastic Arrows Upper Chart
# @MerryDay 7/2022
input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input DPeriod = 10;
input priceH = high;
input priceL = low;
input priceC = close;
input averageType = AverageType.SIMPLE;

def SlowK = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,priceH,priceL,priceC,3,averageType).FullK;
def SlowD = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,priceH,priceL,priceC,3,averageType).FullD;

plot upside = slowk crosses above slowd ;
     upside.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_up);
     upside.SetDefaultColor(color.blue) ;
     upside.SetLineWeight(1);

plot downside = slowk crosses below slowd  ;
     downside.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
     downside.SetDefaultColor(color.red) ;
     downside.SetLineWeight(1);
N7lk0i0.png
 
I was looking for some sort of signal when the FullK and FullD signals crossed and where in the over sold/bought area.

Did not find anything so I modded the included study.

Hope it helps someone.

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2008-2022
#
# StochasticFull Modded to show arrow when FullK and FullD cross and are above/below over bought over sold
#

declare lower;

input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input DPeriod = 10;
input priceH = high;
input priceL = low;
input priceC = close;
input slowing_period = 3;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On FullK", "On FullD", "On FullK & FullD"};
input showCrossoverSignals = {default "No", "Yes"};

def lowest_k = Lowest(priceL, KPeriod);
def c1 = priceC - lowest_k;
def c2 = Highest(priceH, KPeriod) - lowest_k;
def FastK = if c2 != 0 then c1 / c2 * 100 else 0;

plot FullK = MovingAverage(averageType, FastK, slowing_period);
plot FullD = MovingAverage(averageType, FullK, DPeriod);

plot OverBought = over_bought;
plot OverSold = over_sold;

def upK = FullK crosses above OverSold;
def upD = FullD crosses above OverSold;
def downK = FullK crosses below OverBought;
def downD = FullD crosses below OverBought;

plot UpSignal;
plot DownSignal;
switch (showBreakoutSignals) {
case "No":
    UpSignal = Double.NaN;
    DownSignal = Double.NaN;
case "On FullK":
    UpSignal = if upK then OverSold else Double.NaN;
    DownSignal = if downK then OverBought else Double.NaN;
case "On FullD":
    UpSignal = if upD then OverSold else Double.NaN;
    DownSignal = if downD then OverBought else Double.NaN;
case "On FullK & FullD":
    UpSignal = if upK or upD then OverSold else Double.NaN;
    DownSignal = if downK or downD then OverBought else Double.NaN;
}

UpSignal.setHiding(showBreakoutSignals == showBreakoutSignals."No");
DownSignal.setHiding(showBreakoutSignals == showBreakoutSignals."No");

FullK.SetDefaultColor(GetColor(5));
FullD.SetDefaultColor(GetColor(0));
OverBought.SetDefaultColor(GetColor(1));
OverSold.SetDefaultColor(GetColor(1));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);


plot crossUpSignal;
plot crossDownSignal;
switch (showCrossoverSignals) {
case "No":
    crossUpSignal = Double.NaN;
    crossDownSignal = Double.NaN;
case "Yes":
    crossUpSignal = if FullK crosses FullD and FullK >= OverBought and FullD >= OverBought then FullK else Double.NaN;
    crossDownSignal = if FullK crosses FullD and Fullk <= OverSold and FullD <= OverSold then FullD else Double.NaN;

}

crossUpSignal.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
crossUpSignal.SetDefaultColor(Color.Red);

crossDownSignal.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN);
crossDownSignal.SetDefaultColor(Color.Green);
 
Last edited:
I was looking for some sort of signal when the FullK and FullD signals crossed and where in the over sold/bought area.

Did not find anything so I modded the included study.

Hope it helps someone.

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2008-2022
#
# StochasticFull Modded to show arrow when FullK and FullD cross and are above/below over bought over sold
#

declare lower;

input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input DPeriod = 10;
input priceH = high;
input priceL = low;
input priceC = close;
input slowing_period = 3;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On FullK", "On FullD", "On FullK & FullD"};
input showCrossoverSignals = {default "No", "Yes"};

def lowest_k = Lowest(priceL, KPeriod);
def c1 = priceC - lowest_k;
def c2 = Highest(priceH, KPeriod) - lowest_k;
def FastK = if c2 != 0 then c1 / c2 * 100 else 0;

plot FullK = MovingAverage(averageType, FastK, slowing_period);
plot FullD = MovingAverage(averageType, FullK, DPeriod);

plot OverBought = over_bought;
plot OverSold = over_sold;

def upK = FullK crosses above OverSold;
def upD = FullD crosses above OverSold;
def downK = FullK crosses below OverBought;
def downD = FullD crosses below OverBought;

plot UpSignal;
plot DownSignal;
switch (showBreakoutSignals) {
case "No":
    UpSignal = Double.NaN;
    DownSignal = Double.NaN;
case "On FullK":
    UpSignal = if upK then OverSold else Double.NaN;
    DownSignal = if downK then OverBought else Double.NaN;
case "On FullD":
    UpSignal = if upD then OverSold else Double.NaN;
    DownSignal = if downD then OverBought else Double.NaN;
case "On FullK & FullD":
    UpSignal = if upK or upD then OverSold else Double.NaN;
    DownSignal = if downK or downD then OverBought else Double.NaN;
}

UpSignal.setHiding(showBreakoutSignals == showBreakoutSignals."No");
DownSignal.setHiding(showBreakoutSignals == showBreakoutSignals."No");

FullK.SetDefaultColor(GetColor(5));
FullD.SetDefaultColor(GetColor(0));
OverBought.SetDefaultColor(GetColor(1));
OverSold.SetDefaultColor(GetColor(1));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);


plot crossUpSignal;
plot crossDownSignal;
switch (showCrossoverSignals) {
case "No":
    crossUpSignal = Double.NaN;
    crossDownSignal = Double.NaN;
case "Yes":
    crossUpSignal = if FullK crosses FullD and FullK >= OverBought and FullD >= OverBought then FullK else Double.NaN;
    crossDownSignal = if FullK crosses FullD and Fullk <= OverSold and FullD <= OverSold then FullD else Double.NaN;

}

crossUpSignal.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
crossUpSignal.SetDefaultColor(Color.Red);

crossDownSignal.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN);
crossDownSignal.SetDefaultColor(Color.Green);
@fabriciom Thank you so much for sharing this code. Can you please code it so that the arrows show in the upper chart? I would really appreciate it.
 
@fabriciom Thank you so much for sharing this code. Can you please code it so that the arrows show in the upper chart? I would really appreciate it.

Hello,

I don't understand what you mean with the "upper chart".

Do you mean above the over bought and over sold line?

If you want the chart to show in the upper part of your screen like the candle sticks just comment the first line with "#declare lower;".
 
Last edited:
Can anyone make a StochasticMacd buy and sell indicator that uses StochasticMacd and StochasticSlow. Much appreciated in advance.
 
Last edited by a moderator:
I was able to find the below script. I see SleepyZ posted it on someone else's question, either SleepyZ created it or obtained it somewhere else. Either way, I much appreciated it. Not exactly what I was looking for but close enough.

def rsi = reference rsi();
def macdsignal = reference MACD().Diff;
def stoK= reference stochasticfull().fullK;

assignPriceColor(if rsi>50 and stok>50 and macdsignal>0
then color.green
else if rsi<50 and stok<50 and macdsignal<0
then color.red
else color.black);
 
Last edited:
Looking for someone to add crossover arrows to the StochasticMomemtumIndex please. Thank you.
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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