Elastic Stochastic for ThinkorSwim -Upper and Lower indicator

chewie76

Well-known member
VIP
VIP Enthusiast
Are you looking for reversals? The Elastic Stochastic may be a good fit for your trading strategy. This is a twist on the StochasticFull indicator. This does not repaint. This is an elastic indicator because it acts like a rubber band that gets stretched and snaps back. There is a stretching and then a pull back. Typically the longer the stretch goes, the stronger the pull back. This indicator provides both weak and strong signals. The white arrows are weak signals and the magenta arrows are strong signals for reversals. The yellow wedges are indicators that the stock is currently going through a stretch. When you see yellow wedges, expect to see it end with a magenta arrow followed by the snap back. Yellow wedge signals are caution signs. It's letting you know to be prepared for a pull back or correction coming. Be cautious because it can stretch for many candles before you finally get the magenta snap back arrow. This works on any timeframe, but I would suggest you trade longer than the one minute.

The magenta snap back arrows and yellow caution wedges can be adjusted in the settings. So I highly suggest you look at this on many time frames and adjust the sensitivity based on your own preferences. By default, both are set at 80 overbought and 20 oversold. The higher you make the overbought, the less signals you will see. The lower you make the oversold, the less signals you will see. So adjust it to your own preferences.

In the settings, you can also turn off the yellow caution wedges and weak white arrow signals by selecting "No".

Here are some examples followed by a watchlist column. You can use this indicator to create your own scan.

Example of SPY on the 2 min chart. Yellow wedges are stretching and magenta arrow is the snap back. The white arrows are weak reversals.

xyXDI9o.png


Example of /ES on the 2 min chart.

5b4gv5m.png


Example of /NQ on the 4 hour chart.

6GwUts9.png



Here is the Watchlist Column. When there is a yellow wedge up, you see the word "Up" in yellow. A wedge down, you'll see "Down". When there is a magenta up arrow, you'll see "BUY" in magenta, and a down arrow is a magenta "SELL". Weak buy and sell white arrows will say "WBUY" or "WSELL" in white lettering. Below is an example.

ISc48ZM.png


WATCHLIST COLUMN:
http://tos.mx/s6P8ipm

Code:
#Elastic Stochastic Watchlist Column
#Assembled by Chewie on usethinkscript.com

input over_bought = 80;
input over_sold = 20;
input caution_high = 80.0;
input caution_low = 20.0;
input caution = yes;
input KPeriod = 5;
input DPeriod = 3;
input slowing_period = 2;
input smoothingType = {default SMA, EMA};

def priceH = high;
def priceL = low;
def priceC = close;
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;

def fullk;
def FullD;

switch (smoothingType) {
case SMA:
    fullk = Average(FastK, slowing_period);
    FullD = Average(fullk, DPeriod);
case EMA:
    fullk = ExpAverage(FastK, slowing_period);
    FullD = ExpAverage(fullk, DPeriod);
}

def OverBought = over_bought;
def OverSold = over_sold;
def crossedb = Crosses(FullD, overbought, CrossingDirection.BELOW);
def crossbelow =  if crossedb is true then 1 else 0;
def crosseda = Crosses(FullD, oversold, CrossingDirection.above);
def crossabove = if crosseda is true then 1 else 0;
def Caution_UP = FullD > caution_high;
def CautionUP = if caution and Caution_UP is true then 1 else 0;
def Caution_DOWN = FullD < caution_low;
def CautionDOWN = if caution and Caution_DOWN is true then 1 else 0;
def Weak1 = if FullD < 48  and FullD  > 25 and FullD[1] < 48 and FullD[1] < FullD[2] and FullD[2] < 48 and FullD[2] > 25 and FullD  > FullD[1] then FullD else Double.NaN;
plot WeakBUY = if Weak1 is true then 1 else 0;
def Weak2 = if FullD > 52  and FullD  < 75 and FullD[1] > 52 and FullD[1] > FullD[2] and FullD[2] > 52 and FullD[2] <75 and FullD  < FullD[1] then FullD else Double.NaN;
plot WeakSELL = if Weak2 is true then 1 else 0;
def Trending = caution_UP or caution_Down;
def Signal = crosseda or crossedb;

addlabel(yes,
if crossabove then ("BUY")
else if crossedb then ("SELL")
else if WeakBUY then ("WBUY")
else if WeakSELL then ("WSELL")
else if caution_UP then("Up")
else if caution_Down then("Down")
else " ",
if Signal then color.magenta else if WeakBUY and WeakSELL then color.white else if Trending then color.yellow else color.current);

UPPER INDICATOR:
http://tos.mx/sg3pepL

Code:
#Elastic Stochastic Upper with signals
#Assembled by Chewie on usethinkscript.com https://usethinkscript.com/threads/elastic-stochastic-for-thinkorswim-upper-and-lower-indicator.4360/

declare upper;
input snap_high = 80;
input snap_low = 20;
input caution_high = 80.0;
input caution_low = 20.0;
input caution = yes;
input weak = yes;
input KPeriod = 5;
input DPeriod = 3;
input slowing_period = 2;
input smoothingType = {default SMA, EMA};

def priceH = high;
def priceL = low;
def priceC = close;
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;

def fullk;
def FullD;

switch (smoothingType) {
case SMA:
    fullk = Average(FastK, slowing_period);
    FullD = Average(fullk, DPeriod);
case EMA:
    fullk = ExpAverage(FastK, slowing_period);
    FullD = ExpAverage(fullk, DPeriod);
}

def OverBought = snap_high;
def OverSold = snap_low;

def crossedb = Crosses(FullD, overbought, CrossingDirection.BELOW);
plot crossbelow =  if crossedb is true then 1 else 0;
crossbelow.SetDefaultColor(Color.magenta);
crossbelow.SetPaintingStrategy(PaintingStrategy.Boolean_arrow_down);

def crosseda = Crosses(FullD, oversold, CrossingDirection.above);
plot crossabove = if crosseda is true then 1 else 0;
crossabove.SetDefaultColor(Color.magenta);
crossabove.SetPaintingStrategy(PaintingStrategy.Boolean_arrow_up);

def Caution_UP = FullD > caution_high;
plot CautionUP = if caution and Caution_UP is true then 1 else 0;
CautionUP.setDefaultColor(Color.yellow);
CautionUP.SetPaintingStrategy(PaintingStrategy.Boolean_wedge_up);

def Caution_DOWN = FullD < caution_low;
plot CautionDOWN = if caution and Caution_DOWN is true then 1 else 0;
CautionDOWN.setDefaultColor(Color.yellow);
CautionDOWN.SetPaintingStrategy(PaintingStrategy.Boolean_wedge_DOWN);

def Weak1 = if FullD < 48  and FullD  > 25 and FullD[1] < 48 and FullD[1] < FullD[2] and FullD[2] < 48 and FullD[2] > 25 and FullD  > FullD[1] then FullD else Double.NaN;
plot WeakBUY = if weak and Weak1 is true then 1 else 0;
WeakBUY.SetDefaultColor(Color.white);
WeakBUY.SetPaintingStrategy(PaintingStrategy.Boolean_arrow_up);

def Weak2 = if FullD > 52  and FullD  < 75 and FullD[1] > 52 and FullD[1] > FullD[2] and FullD[2] > 52 and FullD[2] <75 and FullD  < FullD[1] then FullD else Double.NaN;
plot WeakSELL = if weak and Weak2 is true then 1 else 0;
WeakSELL.SetDefaultColor(Color.white);
WeakSELL.SetPaintingStrategy(PaintingStrategy.Boolean_arrow_DOWN);

LOWER INDICATOR:
http://tos.mx/REZmVJ8

Code:
#Elastic_Stochastic with signals
#Assembled by Chewie on usethinkscript.com  https://usethinkscript.com/threads/elastic-stochastic-for-thinkorswim-upper-and-lower-indicator.4360/

declare lower;
input over_bought = 80;
input over_sold = 20;
input KPeriod = 5;
input DPeriod = 3;
input slowing_period = 2;
input smoothingType = {default SMA, EMA};

def priceH = high;
def priceL = low;
def priceC = close;
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;
def fullk;
plot FullD;
FullD.SetDefaultColor(color.yellow);

switch (smoothingType) {
case SMA:
    fullk = Average(FastK, slowing_period);
    FullD = Average(fullk, DPeriod);
case EMA:
    fullk = ExpAverage(FastK, slowing_period);
    FullD = ExpAverage(fullk, DPeriod);
}

plot OverBought = over_bought;
plot OverSold = over_sold;
OverBought.SetDefaultColor(Color.red);
OverSold.SetDefaultColor(Color.green);

AddCloud(FULLD, OverBought, Color.RED, Color.CURRENT);
AddCloud(OverSold, FULLD, Color.GREEN, Color.CURRENT);

def crossedb = Crosses(FullD, overbought, CrossingDirection.BELOW);
plot crossbelow = if crossedb then crossedb + overbought else Double.NaN;
crossbelow.SetDefaultColor(Color.magenta);
crossbelow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

def crossedu = Crosses(FullD, oversold, CrossingDirection.ABOVE);
plot crossabove = if crossedu then crossedu + oversold else Double.NaN;
crossabove.SetDefaultColor(Color.magenta);
crossabove.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

def Weak1 = if FullD < 48  and FullD  > 25 and FullD[1] < 48 and FullD[1] < FullD[2] and FullD[2] < 48 and FullD[2] > 25 and FullD  > FullD[1] then FullD else Double.NaN;
plot WeakBUY = Weak1;
WeakBUY.SetDefaultColor(Color.white);
WeakBUY.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

def Weak2 = if FullD > 52  and FullD  < 75 and FullD[1] > 52 and FullD[1] > FullD[2] and FullD[2] > 52 and FullD[2] <75 and FullD  < FullD[1] then FullD else Double.NaN;
plot WeakSELL = Weak2;
WeakSELL.SetDefaultColor(Color.white);
WeakSELL.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

STRATEGY LINK:
It actually triggers on the candle after the magenta signal. http://tos.mx/LGQBZmk

Enjoy!
 
Last edited:

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

@chewie76 Thank you for your recent efforts to provide the uTS Community with new and interesting thinkscripts. On that note, I've taken the liberty of creating two Elastic Stochastic scans for your and the community's review...Since the original script could not provide one scan, I've divided it into two...one SMA version and one EMA version...

Elastic Stochastic SMA SCAN

Code:
input over_bought = 80;
input over_sold = 20;
input KPeriod = 5;
input DPeriod = 3;
input slowing_period = 2;

def priceH = high;
def priceL = low;
def priceC = close;
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;
def FullK = Average(FastK, slowing_period);
def FullD = Average(fullk, DPeriod);

def OverBought = over_bought;
def OverSold = over_sold;

def crossedb = Crosses(FullD, overbought, CrossingDirection.BELOW);
def crossedu = Crosses(FullD, oversold, CrossingDirection.ABOVE);

# Note: Comment out (using the # sign) to run either the Bear or Bull SMA Scan statement below

# Elastic Stochastic Bear SMA Scan
#plot crossbelow = if crossedb then crossedb + overbought else Double.NaN;

# Elastic Stochastic Bull SMA Scan
plot crossabove = if crossedu then crossedu + oversold else Double.NaN;

Elastic Stochastic EMA SCAN

Code:
input over_bought = 80;
input over_sold = 20;
input KPeriod = 5;
input DPeriod = 3;
input slowing_period = 2;

def priceH = high;
def priceL = low;
def priceC = close;
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;
def FullK = ExpAverage(FastK, slowing_period);
def FullD = ExpAverage(FullK, DPeriod);

def OverBought = over_bought;
def OverSold = over_sold;

def crossedb = Crosses(FullD, overbought, CrossingDirection.BELOW);
def crossedu = Crosses(FullD, oversold, CrossingDirection.ABOVE);

# Note: Comment out (using the # sign) to run either the Bear or Bull EMA Scan statement below

# Elastic Stochastic EMA Bear Scan
#plot crossbelow = if crossedb then crossedb + overbought else Double.NaN;

# Elastic Stochastic EMA Bull Scan
plot crossabove = if crossedu then crossedu + oversold else Double.NaN;


Good Luck and Good Trading :)
 
Great job on this indicator - Just a FYI - in the description of the it mentions that the indicator does not repaint. The yellow wedges will repaint
 
Yes and No - I do wait for the close of the candle. Just wanted to put that out there so anyone new to trading does not just jump in on a yellow wedge signal. I have seen some other indicators that talk about using them for scalping. In my opinion all indicators re paint. You must wait for confirmation with close of candle
 
great indicator.. thank you some much for sharing with us.. a quick question, can someone here in the group can add buy and sell order strategy for backtesting? the buy and sell order only on the buy and sell arrow..thank you an advance..
 
great indicator.. thank you some much for sharing with us.. a quick question, can someone here in the group can add buy and sell order strategy for backtesting? the buy and sell order only on the buy and sell arrow..thank you an advance..
Here is the strategy. It actually triggers on the candle after the magenta signal. http://tos.mx/LGQBZmk
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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