Triple Exhaustion Indicator For ThinkOrSwim

Check to see if all criteria was coded as you indicated. Hopefully this is what you were looking for.

Triple Exhaustion Indicator

4TxCJVA.jpg


Ruby:
## Triple Exhaustion Indicator
##
##
## CREDITS
## Requested by @Chence27 from criteria listed here https://usethinkscript.com/threads/triple-exhaustion-indicator.9001/
##
##
## Removing the header Credit credits and description is not permitted, any modification needs to be shared.
##
## V 1.0 :    @cos251 - Initial release per request from www.usethinkscript.com forum thread:
##       :    https://usethinkscript.com/threads/triple-exhaustion-indicator.9001/
##
##
##

declare upper;

# --- Inputs
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;
input length = 1000;
input paintBars = yes;
input showLabels = yes;


# --- Indicators - StochasticSlow / MACD / MACD StDev / DMI+/-
def SlowK = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageType).FullK;
def MACD = reference MACD()."Value";
def priceMean = Average(MACD, length);
def MACD_stdev =  (MACD - priceMean) / StDev(MACD, length);
def dPlus = reference DMI()."DI+";
def dMinus = reference DMI()."DI-";
# --- End Indicators

# --- Conditions
def sellerRegular = SlowK < 20 and MACD_stdev < -1 and dPlus < 15;
def sellerExtreme = SlowK < 20 and MACD_stdev < -2 and dPlus < 15;
def buyerRegular = SlowK > 80 and MACD_stdev > 1 and dMinus < 15;
def buyerExtreme = SlowK > 80 and MACD_stdev > 2 and dMinus < 15;
# --- End Conditions

# -- Price Color
AssignPriceColor( if paintBars and sellerExtreme then Color.CYAN else if buyerExtreme and paintBars then Color.GREEN else if paintBars and sellerRegular then Color.YELLOW else if buyerRegular and paintBars then Color.DARK_GREEN else if paintBars then Color.GRAY else Color.Current);

# --- Arrows/Triggers
plot RegularBuy = if sellerRegular[1] and !sellerRegular then low else Double.NaN;
plot ExtremeBuy = if sellerExtreme[1] and !sellerExtreme then low else Double.NaN;
RegularBuy.SetPaintingStrategy(PaintingSTrategy.ARROW_UP);
ExtremeBuy.SetPaintingSTrategy(paintingSTrategy.Arrow_UP);
RegularBuy.SetDefaultColor(Color.LIME);
ExtremeBuy.SetDefaultColor(Color.GREEN);

plot RegularSell = if buyerRegular[1] and !buyerRegular then high else Double.NaN;
plot ExtremeSell = if buyerExtreme[1] and !buyerExtreme then high else Double.NaN;
RegularSell.SetPaintingStrategy(PaintingSTrategy.ARROW_Down);
ExtremeSell.SetPaintingSTrategy(paintingSTrategy.Arrow_DOWN);
RegularSell.SetDefaultColor(Color.Light_RED);
ExtremeSell.SetDefaultColor(Color.RED);

# --- Labels
AddLabel(showLabels,"SellerRegular",Color.YELLOW);
AddLabel(showLabels,"SellerExtreme",Color.CYAN);
AddLabel(showLabels,"BuyerRegular",Color.DARK_GREEN);
AddLabel(showLabels,"BuyerExtreme",Color.GREEN);


Triple Exhaustion Indicator SCAN (Scanner)
Ruby:
## Triple Exhaustion Indicator SCAN
##
##
## CREDITS
## Requested by @Chence27 from criteria listed here https://usethinkscript.com/threads/triple-exhaustion-indicator.9001/
## SCAN requested by @Trader_Andrew
##
## Removing the header Credit credits and description is not permitted, any modification needs to be shared.
##
## V 1.0 :    @cos251 - Initial release per request from www.usethinkscript.com forum thread:
##       :    https://usethinkscript.com/threads/triple-exhaustion-indicator.9001/
##       :    SCAN version requested by @Trader_Andrew
##
##
##


# --- Inputs
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;
input length = 1000;
input paintBars = yes;
input showLabels = yes;


# --- Indicators - StochasticSlow / MACD / MACD StDev / DMI+/-
def SlowK = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageType).FullK;
def MACD = reference MACD()."Value";
def priceMean = Average(MACD, length);
def MACD_stdev =  (MACD - priceMean) / StDev(MACD, length);
def dPlus = reference DMI()."DI+";
def dMinus = reference DMI()."DI-";
# --- End Indicators

# --- Conditions
def sellerRegular = SlowK < 20 and MACD_stdev < -1 and dPlus < 15;
def buyerRegular = SlowK > 80 and MACD_stdev > 1 and dMinus < 15;
# --- End Conditions

# --- Arrows/Triggers
plot RegularBuyArrow = if sellerRegular[1] and !sellerRegular then 1 else Double.NaN;
plot RegularSellArrow = if buyerRegular[1] and !buyerRegular then 1 else Double.NaN;
plot RegularBuyTrendExists = if sellerRegular then 1 else Double.NaN;
plot RegularSellTrendExists = if buyerRegular then 1 else Double.NaN;
Nice indicator. I am very interested in the scan here. I tried adding this custom scan to thinkorswim but the OK button is greyed out. Are you able to add it the same way I am? See https://snipboard.io/4ozJIE.jpg. Thx.
 
## Triple Exhaustion Indicator SCAN ## ## ## CREDITS ## Requested by @Chence27 from criteria listed here https://usethinkscript.com/threads/triple-exhaustion-indicator.9001/ ## SCAN requested by @Trader_Andrew ## ## Removing the header Credit credits and description is not permitted, any modification needs to be shared. ## ## V 1.0 : @cos251 - Initial release per request from www.usethinkscript.com forum thread: ## : https://usethinkscript.com/threads/triple-exhaustion-indicator.9001/ ## : SCAN version requested by @Trader_Andrew ## ## ## # --- Inputs 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; input length = 1000; input paintBars = yes; input showLabels = yes; # --- Indicators - StochasticSlow / MACD / MACD StDev / DMI+/- def SlowK = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageType).FullK; def MACD = reference MACD()."Value"; def priceMean = Average(MACD, length); def MACD_stdev = (MACD - priceMean) / StDev(MACD, length); def dPlus = reference DMI()."DI+"; def dMinus = reference DMI()."DI-"; # --- End Indicators # --- Conditions def sellerRegular = SlowK < 20 and MACD_stdev < -1 and dPlus < 15; def buyerRegular = SlowK > 80 and MACD_stdev > 1 and dMinus < 15; # --- End Conditions # --- Arrows/Triggers plot RegularBuyArrow = if sellerRegular[1] and !sellerRegular then 1 else Double.NaN; plot RegularSellArrow = if buyerRegular[1] and !buyerRegular then 1 else Double.NaN; plot RegularBuyTrendExists = if sellerRegular then 1 else Double.NaN; plot RegularSellTrendExists = if buyerRegular then 1 else Double.NaN;
Are you all able to to add this scan in TOS? My OK button is greyed out when I try.
 
SQ a good example of the TMO keeping us out of trying to catch the falling knife. Friday's daily candle gave us a buy print with a candle color change from BuyerExtreme to grey, but the TMO was screaming at us to stay the hell out.
 
Here`s a modified upper study TMO with vertical lines.


# TMO ((T)rue (M)omentum (O)scilator)
# Mobius
# V01.05.2018
# hint: TMO calculates momentum using the delta of price. Giving a much better picture of trend, tend reversals and divergence than momentum oscillators using price.

declare Upper;

input length = 14;
input calcLength = 5;
input smoothLength = 3;

def o = open;
def c = close;
def data = fold i = 0 to length
with s
do s + (if c > getValue(o, i)
then 1
else if c < getValue(o, i)
then - 1
else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);

def zero = if isNaN(c) then double.nan else 0;

def ob = if isNaN(c) then double.nan else round(length * .7);

def os = if isNaN(c) then double.nan else -round(length * .7);
#___________________________________________________________________add_on
def BUYsignal =Main < OS and Main crosses above Signal;
def SELLsignal = Main > OB and Main crosses below Signal;

addverticalline(BUYsignal,"Buy",color.green,curve.short_dash);
addverticalline(SELLsignal,"Sell",color.red,curve.short_dash);

# End Code TMO

Thank you for this!
 
Hello COS251! Your code for Triple Exhaustion is much appreciated. I've been able to use the SCAN code to find triggers, however it's not working on a day timeframe. Any ideas how I could enable this? Thank you!
Try reducing the "length" to 799 or less for the daily timeframe. When it is set to 1000 there is not enough information on the chart to do the calculation.
 
Nice indicator. I am very interested in the scan here. I tried adding this custom scan to thinkorswim but the OK button is greyed out. Are you able to add it the same way I am? See https://snipboard.io/4ozJIE.jpg. Thx.
That´s because you have multiple plots in your scan, you need to have only one for each scan condition so for example, if you want to scan for bull arrow up, remove all the other plots or blank them using # and leave only the arrow up plot. Then your OK button will be avaliable again.
 
@cos251
What's the difference between these 2 pieces of code:

FVO Scanner
# --- Arrows/Triggers
plot RegularBuyArrow = if sellerRegular[1] and !sellerRegular then 1 else Double.NaN;
plot RegularSellArrow = if buyerRegular[1] and !buyerRegular then 1 else Double.NaN;

Triple Indicator Study
# --- Arrows/Triggers
plot RegularBuy = if sellerRegular[1] and !sellerRegular then low else Double.NaN;
plot RegularSell = if buyerRegular[1] and !buyerRegular then high else Double.NaN;

I've noticed the bottom code gives more false arrows, than the top. How does using '1' vs using 'high/low', affect the study?
 
Here`s a modified upper study TMO with vertical lines.


# TMO ((T)rue (M)omentum (O)scilator)
# Mobius
# V01.05.2018
# hint: TMO calculates momentum using the delta of price. Giving a much better picture of trend, tend reversals and divergence than momentum oscillators using price.

declare Upper;

input length = 14;
input calcLength = 5;
input smoothLength = 3;

def o = open;
def c = close;
def data = fold i = 0 to length
with s
do s + (if c > getValue(o, i)
then 1
else if c < getValue(o, i)
then - 1
else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);

def zero = if isNaN(c) then double.nan else 0;

def ob = if isNaN(c) then double.nan else round(length * .7);

def os = if isNaN(c) then double.nan else -round(length * .7);
#___________________________________________________________________add_on
def BUYsignal =Main < OS and Main crosses above Signal;
def SELLsignal = Main > OB and Main crosses below Signal;

addverticalline(BUYsignal,"Buy",color.green,curve.short_dash);
addverticalline(SELLsignal,"Sell",color.red,curve.short_dash);

# End Code TMO
For these variables
input length = 14;
input calcLength = 5;
input smoothLength = 3;

Can you explain the logic? I am asking because I was using one with 21, 5, and 3 and I wanted to know what exact data they affect. Thanks.
 
Anyone can help creating custom watchlist columns for the 4 different trend buy & sell conditions and color them according to study?
 
@cos251
What's the difference between these 2 pieces of code:

FVO Scanner
# --- Arrows/Triggers
plot RegularBuyArrow = if sellerRegular[1] and !sellerRegular then 1 else Double.NaN;
plot RegularSellArrow = if buyerRegular[1] and !buyerRegular then 1 else Double.NaN;

Triple Indicator Study
# --- Arrows/Triggers
plot RegularBuy = if sellerRegular[1] and !sellerRegular then low else Double.NaN;
plot RegularSell = if buyerRegular[1] and !buyerRegular then high else Double.NaN;

I've noticed the bottom code gives more false arrows, than the top. How does using '1' vs using 'high/low', affect the study

The top one is for the scan (value = true) the second one is for the indicator. Sorry, should have updated the comment as well.
Same result though.
 
The top one is for the scan (value = true) the second one is for the indicator. Sorry, should have updated the comment as well.
Same result though.
Thanks for the reply. I'm not getting the same results tho. The FVO top one, triggers the arrow indicator less times then the bottom one.
 
Thanks for the reply. I'm not getting the same results tho. The FVO top one, triggers the arrow indicator less times then the bottom one.
Not sure how that is possible, it is the exact same code. I just use a "1" in the scans for simplification. Either the plot has a value (ie. it is "true") or it doesn't and equals Double.NaN.

For the "low" version, the "low" is used so the arrow is plotted under the low of the corresponding candle.
 
Triple Exhaustion Indicator For ThinkOrSwim
This is a pretty powerful indicator showing buy and sell exhaustion (MACD, Stochastic and DMI all in an extreme condition). When the exhaustion ends, expect a reversal. Thank you @cos251 for the code!

Code:
## Triple Exhaustion Indicator
##
##
## CREDITS
## Requested by @Chence27 from criteria listed here https://usethinkscript.com/threads/triple-exhaustion-indicator.9001/
##
##
## Removing the header Credit credits and description is not permitted, any modification needs to be shared.
##
## V 1.0 :    @cos251 - Initial release per request from www.usethinkscript.com forum thread:
##       :    https://usethinkscript.com/threads/triple-exhaustion-indicator.9001/
## V 1.1 : @chence27 - modifcations to better approximate original study
##
##
##

declare upper;

# --- Inputs
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;
input length = 1000;
input paintBars = yes;
input showLabels = yes;


# --- Indicators - StochasticSlow / MACD / MACD StDev / DMI+/-
def SlowK = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageType).FullK;
def MACD = reference MACD()."Value";
def priceMean = Average(MACD, length);
def MACD_stdev =  (MACD - priceMean) / StDev(MACD, length);
def dPlus = reference DMI()."DI+";
def dMinus = reference DMI()."DI-";
# --- End Indicators

# --- Conditions
def sellerRegular = SlowK < 20 and MACD_stdev < -1 and dPlus < 15;
def sellerExtreme = SlowK < 20 and MACD_stdev < -2 and dPlus < 15;
def buyerRegular = SlowK > 80 and MACD_stdev > 1 and dMinus < 15;
def buyerExtreme = SlowK > 80 and MACD_stdev > 2 and dMinus < 15;
# --- End Conditions

# -- Price Color
AssignPriceColor( if paintBars and sellerExtreme then Color.CYAN else if buyerExtreme and paintBars then Color.MAGENTA else if paintBars and sellerRegular then Color.GREEN else if buyerRegular and paintBars then Color.RED else if paintBars then Color.GRAY else Color.Current);

# --- Arrows/Triggers
plot RegularBuy = if sellerRegular[1] and !sellerRegular then low else Double.NaN;

RegularBuy.SetPaintingStrategy(PaintingSTrategy.ARROW_UP);

RegularBuy.SetDefaultColor(Color.GREEN);


plot RegularSell = if buyerRegular[1] and !buyerRegular then high else Double.NaN;

RegularSell.SetPaintingStrategy(PaintingSTrategy.ARROW_Down);

RegularSell.SetDefaultColor(Color.RED);


# --- Labels
AddLabel(showLabels,"SellerRegular",Color.RED);
AddLabel(showLabels,"SellerExtreme",Color.MAGENTA);
AddLabel(showLabels,"BuyerRegular",Color.GREEN);
AddLabel(showLabels,"BuyerExtreme",Color.CYAN);


VSftwHT.png

3R1WY6H.png
How do i use this as a scanner filter? Is alrdy added to studies, and i tried selecting buy/sell for plot and condition is true. but no match
 
For these variables
input length = 14;
input calcLength = 5;
input smoothLength = 3;

Can you explain the logic? I am asking because I was using one with 21, 5, and 3 and I wanted to know what exact data they affect. Thanks.
Lower input length means faster reaction to price. I would open two instances of the study and compare the results for each input length.
 
At home today so I'm able to watch this perform on the 10 minute charts. I generally don't intraday trade/scalp. When a sell signal appears at the opening of a candle, it takes a lot of patience to wait for that candle to print before entering. From what I am seeing, though, it is definitely worth the patience to wait!
 
Not sure how that is possible, it is the exact same code. I just use a "1" in the scans for simplification. Either the plot has a value (ie. it is "true") or it doesn't and equals Double.NaN.

For the "low" version, the "low" is used so the arrow is plotted under the low of the corresponding candle.
I've been going back and forth on this all morning lol, please see the image below.
On the left is the study, on the right is the scan. I only changed the smoothing and added the arrow logic to the Scan so they could match but as you see, they give different results. All the settings are the same too.

The arrow is not printing BUT is that because of high vs 1? Because i'll run the scan and the arrow will be on the chart, but the ticker doesnt show up in the scan.

 
Exactly, it´s the signal you want to wait for to line up on both indicators and i even blanked out the OB & OS part of the code on my TMO study and then overlaid only the signal lines on the upper chart which makes the signals even more clear to see. I like it a lot on the 10min timeframe but also the 4/5min works well.
Would you be willing to post it or post a link to this?
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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