# Leledc Exhaustion Indicator for ThinkorSwim

J

#### Jenny

##### New member
VIP
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 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.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");

#### MattATM

##### Active member
VIP
@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

J

#### Jenny

##### New member
VIP
Hi Matt

Thanks for offering to help. Hope the image showed below :

Basically I keyed in 1 point SL for the ES ( the code supposedly allow for any adjustments on the profit / SL) but as per the P/L, it did not execute the SL at 1 point.

Thanks again for trying

A

#### Alex

##### Member
VIP
Could anybody help me make the signal appear as a painted candle instead of an arrow? much thx

I tried using "AssignPriceColor" but didn't work.

#### BenTen

Staff
VIP
@Alex Here you go:

Code:
``````#Leledc Exhaustion Port
#Joy_Bangla
#
#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.
#
#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;
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);

def pUP = major == 1;
def pDown = major == -1;

AssignPriceColor(if pUp then color.green else if pDown then color.red else color.white);``````

B

#### Bhai

##### New member
i'm trying to create the scanner, its not working

#### BenTen

Staff
VIP
@Bhai Middle column should be "is true" instead of "is equal to"

#### scott69

##### Member
Just like any other indicator, employing a study that identifies reversal candles needs to be used in conjunction with other indicators (stochastic, RSI, ADX) to support the reversal. Plus, the longer the time frame, the more accurate the reversal. Looking at a 1 minute chart, for instance, you can have multiple reversal candles in a row, and then price action continues on its merry way in the same direction as before. Watching the 15 minute chart for these, the signals have a higher accuracy percent for the turn. Personally, I have always made it a point to watch price structure, i.e. candle and pattern formation. It is probably THE most important observation. This is a nice study, though. Thanks to the traders that worked on it.

B

#### Bhai

##### New member
hi @BenTen - I tried the "is true" but still not getting any result.
i changed the bar from 1 to 10 values. and different time (1h, 1d) - still not getting any result.