Leledc Exhaustion Indicator for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
Leledc Exhaustion Bar does a great job of pointing out when a trend may be coming to an end.

An Exhaustion Bar is a bar which signals the exhaustion of the trend in the current direction. In other words, an exhaustion bar is “A bar of the last seller” in case of a downtrend and “A bar of last buyer” in case of an uptrend. Having said that when a party cannot take the price further in their direction, naturally the other party comes in, takes charge and reverses the direction of the trend.

Note: This indicator does not repaint ;)

Luo4qxj.png


Q3ULsAL.png


thinkScript Code

Code:
#Leledc Exhaustion Port
#Joy_Bangla
#
#https://www.tradingview.com/script/pQv1kge2-Leledc-Exhaustion-V4/
#The Psychology
#Let's assume that we have a group of people, say 100 people who decide to go for a casual running.
#After running for a few KM's few of them will say “I am exhausted. I cannot run further”.
#They will quit running. After running further, another bunch of runners will say I am exhausted. I can’t run further
#and they also will quit running. This goes on and on and then there will be a stage where only a few will be left
#in the running. Now a stage will come where the last person left in the running will say am exhausted and he stops running.
#That means no one is left now in the running. This means all are exhausted in the running.
#
#The same way an exhaustion bar works. The reason is an exhaustion bar sometimes formed at almost tops and bottoms.
#
#Timeframe
#The exhaustion bars are found on all Time frames as a trend also exists on all Timeframes.
#However, as a thumb rule Higher the Time frame, higher will be the accuracy as well as the profitability.
#
#Trading the Leledec Exhaustion Bars
#I may trade as soon as it is shown on the chart.
#I may trade when price breaks the high/low of the bar depending on whether I am getting bullish or bearish signal
#I may trade when price breaks the high/low of the bar depending on whether I am getting bullish or bearish signal.
#I may also be looking to ensure the current volume is higher than the previous few
#(? how many?) bar volumes.
#
# Ported 2019.11.16
# Release 1.0
#

input maj_qual = 6;
input maj_len = 30;


script lele {
    input qual = 6; #default major
    input len = 30; #default major

    def bIndex = CompoundValue(1,
     if (bIndex[1] > qual) and (close < open) and high >= Highest(high, len) then 0 else
     if (close > close[4]) then bIndex[1] + 1 else bIndex[1]
    , 0);

    def sIndex = CompoundValue(1,
     if ((sIndex[1] > qual) and (close > open) and (low <= Lowest(low, len))) then 0 else
     if (close < close[4]) then sIndex[1] + 1 else sIndex[1]
    , 0);

    def ret =
     if (bIndex[1] > qual) and (close < open) and high >= Highest(high, len) then -1 else
     if ((sIndex[1] > qual) and (close > open) and (low <= Lowest(low, len))) then 1
    else 0;

    plot sData = ret;
}

#PLOTS

def major = lele(maj_qual,maj_len);

plot pUP = major == 1;
pUP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
pUP.SetDefaultColor(Color.GREEN);
pUP.SetLineWeight(2);

plot pDown = major == -1;
pDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
pDown.SetDefaultColor(Color.RED);
pDown.SetLineWeight(2);

# Alerts
Alert(pUP, " ", Alert.Bar, Sound.Chimes);
Alert(pDown, " ", Alert.Bar, Sound.Bell);
 
Last edited by a moderator:
Hi Ben

Thanks for sharing. Looks interesting especially when it doenst repaint . Can you help by adding an audio alert on the arrows? Thanks !
 
Some of the code is not used. Took it out.

Code:
input maj_qual = 6;
input maj_len = 30;


script lele {
    input qual = 6; #default major
    input len = 30; #default major

    def bIndex = CompoundValue(1,
     if (bIndex[1] > qual) and (close < open) and high >= Highest(high, len) then 0 else
     if (close > close[4]) then bIndex[1] + 1 else bIndex[1]
    , 0);

    def sIndex = CompoundValue(1,
     if ((sIndex[1] > qual) and (close > open) and (low <= Lowest(low, len))) then 0 else
     if (close < close[4]) then sIndex[1] + 1 else sIndex[1]
    , 0);

    def ret =
     if (bIndex[1] > qual) and (close < open) and high >= Highest(high, len) then -1 else
     if ((sIndex[1] > qual) and (close > open) and (low <= Lowest(low, len))) then 1
    else 0;

    plot sData = ret;
}

#PLOTS

def major = lele(maj_qual,maj_len);

plot pUP = major == 1;
pUP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
pUP.SetDefaultColor(Color.GREEN);
pUP.SetLineWeight(2);

plot pDown = major == -1;
pDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
pDown.SetDefaultColor(Color.RED);
pDown.SetLineWeight(2);
 
input maj_qual = 12;#6
input maj_len = 45;#30
script lele {
input qual =12; #6 default major
input len = 45; #30 default major

I am finding the above a little more dependable on the 1 minute timeline

Also the authors mentioned a NO SUPPLY NO DEMAND indicator that I am guessing from their statements elsewhere they are using alongside this indicator. I bet it is like a hangtime of sorts. https://www.abundancetradinggroup.com/nsnd-mt4-indicator/ I bet that removes false positives from the exhaustion

They crowdsourced this work amongst tradeview and mt4 communities. They sell other unrelated scripts. I will get mt4 or a file opener later unless someone else who already has mt4 could post the code?
Matt, did you replace the similar code in the study, or add this piece of code to the study?
 
Thanks @BenTen and @diazlaz on the above. I am just trying out on a 10 mins /ES to see how well it works. @BenTen, or anyone who can help with coding ..

can you help to convert it the above exhaustion bar into strategy whereby an entry ( either long or short) whenever the arrows complete the bar and to exit with a 4 points ? I would like to see if the report generated makes sense...Thanks a lot!
 
@Jenny Here is a simple backtesting strategy of the indicator. Not precisely the buy and sell condition you want, but it's a good start if you want to modify it to fit your needs.
  • Go long = up arrow
  • Exit position = down arrow
Code:
# Basic backtesting strategy for Leledc Exhaustion
# Ported to ThinkorSiwm by @diazlaz

input maj_qual = 6;
input maj_len = 30;
input min_qual = 5;
input min_len = 5;

input showMajor = yes; #show major
input showMinor = no; #show minor

script lele {
    input qual = 6; #default major
    input len = 30; #default major

    def bIndex = CompoundValue(1,
     if (bIndex[1] > qual) and (close < open) and high >= Highest(high, len) then 0 else
     if (close > close[4]) then bIndex[1] + 1 else bIndex[1]
    , 0);

    def sIndex = CompoundValue(1,
     if ((sIndex[1] > qual) and (close > open) and (low <= Lowest(low, len))) then 0 else
     if (close < close[4]) then sIndex[1] + 1 else sIndex[1]
    , 0);

    def ret =
     if (bIndex[1] > qual) and (close < open) and high >= Highest(high, len) then -1 else
     if ((sIndex[1] > qual) and (close > open) and (low <= Lowest(low, len))) then 1
    else 0;

    plot sData = ret;
}

#PLOTS

def major = lele(maj_qual,maj_len);

plot pUP = major == 1;
pUP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
pUP.SetDefaultColor(Color.GREEN);
pUP.SetLineWeight(2);

plot pDown = major == -1;
pDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
pDown.SetDefaultColor(Color.RED);
pDown.SetLineWeight(2);

AddOrder(OrderType.BUY_TO_OPEN, condition = pUP, price = close,1, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Long");
AddOrder(OrderType.SELL_TO_CLOSE, condition = pDown, price = close,1, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Cover");
 
Hi All

Wonder if anyone can help me out. I have been trying out this exhaustion bar on the /ES and it seem to work well. Ben posted the entry when the bar bars appear and exit when the next opposite bar closes. I am trying to see if I can work out taking a profit of 4 points and SL of 1 point on the ES with no further trade as long as there's open position/ am trying to see if the strategy report generated makes sense. But I tried the below code on the entry and exit and did not generate a preferred SL ...Can anyone help me to take a look on the orders? Thank you and much appreciated

Code:
input profit=16;

input stop=1;

input size=1;

INPUT long_trades=yes;

input short_trades=yes;

input maj_qual = 6;

input maj_len = 30;

input min_qual = 5;

input min_len = 5;

input showMajor = yes; #show major

input showMinor = no; #show minor

script lele

{

input qual = 6; #default major

input len = 30; #default major

def bIndex = CompoundValue(1, if (bIndex[1] > qual) and (close < open) and high >= Highest(high, len) then 0 else if (close > close[4]) then bIndex[1] + 1 else bIndex[1] , 0); def sIndex = CompoundValue(1, if ((sIndex[1] > qual) and (close > open) and (low <= Lowest(low, len))) then 0 else if (close < close[4]) then sIndex[1] + 1 else sIndex[1] , 0); def ret = if (bIndex[1] > qual) and (close < open) and high >= Highest(high, len) then -1 else if ((sIndex[1] > qual) and (close > open) and (low <= Lowest(low, len))) then 1 else 0;

plot sData = ret; } #PLOTS

def major = lele(maj_qual,maj_len);

plot pUP = major == 1;

pUP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

pUP.SetDefaultColor(Color.GREEN); pUP.SetLineWeight(2);

plot pDown = major == -1; pDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); pDown.SetDefaultColor(Color.RED);

pDown.SetLineWeight(2);

AddOrder(OrderType.BUY_TO_OPEN, long_trades and pUP, price = close,size, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Long");

AddOrder(OrderType.SELL_TO_CLOSE, low<=entryPrice()-stop,low,size, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "STOP");

AddOrder(OrderType.SELL_TO_CLOSE, HIGH>=entryPrice()+profit,high,size, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "SELL");



AddOrder(OrderType.sell_TO_OPEN, short_trades and pdown, price = close,size, tickcolor = Color.red, arrowcolor = Color.red, name = "SHORT");

AddOrder(OrderType.buy_TO_CLOSE, low<=entryPrice()-stop,low,size, tickcolor = Color.red, arrowcolor = Color.red, name = "COVER");

AddOrder(OrderType.buy_TO_CLOSE, HIGH>=entryPrice()+profit,high,size, tickcolor = Color.red, arrowcolor = Color.red, name = "STOP");



# Alerts

Alert(pUP, " ", Alert.Bar, Sound.Chimes);

Alert(pDown, " ", Alert.Bar, Sound.Bell);
 
@Jenny could you please attach a chart and I will try to see what is up with your P/L...
I am not super familiar with this sort of strategy but I will try when I have a free moment
 

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
332 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