Three Bar Reversal Pattern and Indicator for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
Three-bar reversal is a powerful pattern for day trading. The setup looks for a few consecutive red candlesticks and the final bar being a green candle closing higher than previous bars.

Here is an example:

ffdQorx.png


Below is the code to identify bullish trigger bar in the Three Bar Reversal pattern. It also comes with an alert system.

thinkScript Code

Rich (BB code):
# Three-Bar Reversal Indicator
# Found in the thinkScript Archive
# Alert added by WalkingBallista
# https://usethinkscript.com/d/187-three-bar-reversal-pattern-and-indicator-for-thinkorswim

def TBRup = close > open[1] and close[1] < close[2]  and close[2] < close[3] and close[3] < close[4];
plot bullish = if TBRup then high else Double.NaN;
bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
alert(bullish,"TBR Up", alert.Bar,sound.ding);

Shareable Link

https://tos.mx/pLfTyM

If you would like to look for bearish trigger bar in this pattern, you can insert the following code into that indicator.

Rich (BB code):
def TBRdown = close < open[1] and close[1] > close[2] and close[2] > close[3] and close[3] > close[4];
plot bearish = if TBRdown then low else Double.NaN;
bearish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
alert(bearish,"TBR Down", alert.Bar, sound.ding);

The script was posted on the thinkScript Lounge Archive. It did not mention who created the indicator.
 
Last edited:

mohitdas

New member
VIP
@BenTen I would like to add a label to top left corner side of the chart, how should i write the AddLabel command for above charts to show if currently in TBRUP or TBRDown status.Thank You
 

lukeskywalker

New member
This indicator indicates the place of three bar reversal with arrows on the chart📈. The formation is quite specific. Not many people know about it.

⚙Let's place the indicator according to the "three bar reversal" pattern. We'll choose a 5-minute timeframe for that. Import indicator by using <Edit Studies> menu. It will appear on the list. You need to enter Studies – User Defined. Click on the necessary indicator and add - "Add Study".
________________
Code:
#thinkscript indicator: Three_Bar_Reversal.
#Shows the pattern "Three Bar Reversal"
#by thetrader.top

def bSignalDown = open[2]<close[2] and low[1]>low[2] and low[1]<high[2] and high[1]>high[2] and high<high[1] and close[1]<low[1];
def bSignalUp = open[2]>close[2] and low[1]<low[2] and low[2]<high[1] and low[1]<low[2] and low>low[1] and low<high[1] and close>high[1];
plot down = if bSignalDown then high else double.NaN;
plot up = if bSignalUp then high else double.NaN;
up.SetPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_up);
down.SetPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_down);
up.setDefaultColor(color.LIGHT_green);
down.setDefaultColor(color.LIGHT_red);

w7etRp5.png
 
Last edited by a moderator:

asragov

Member
2019 Donor
VIP
@lukeskywalker Apologies if I'm doing something wrong - I get a lot of hits with the scan for the down arrow, but it seems to find nothing for the up arrow - could you please take a look? It is a very interesting approach - thanks
 

LynnChen

New member
Hi Ben, The three bars reversal indicator is excellent! but can you change the last green candle must higher then the previous candle's wick not the close. Thank you so much!
 

RushPro808

New member
VIP
BenTen is big pimpin! Appreciate all the hard work you put into this. I will be referencing this site and yourself on anything I use or modify. Cheers!
 

LynnChen

New member
Yes BenTen the last green candle should close one penny higher than the high of the previous candle. I have been using the TBR conjunction with other indicator from this Forums, they work so well and less emotion to trade. Thank you so much!
 

BenTen

Administrative
Staff member
Staff
VIP
@LynnChen Try this:

Code:
# Generation time: 2020-08-05T22:36:03.729Z

def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
plot PatternPlot =
    IsDown[3] and
    IsDown[2] and
    IsDown[1] and
    IsUp[0] and
    high[1] < close[0];

PatternPlot.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
PatternPlot.SetDefaultColor(GetColor(0));
 

DudeDastic

New member
@BenTen Love the idea of this indicator. But testing reveals it doesn't work on every legit reversal (like when there's a gap between the first and the second bar, and when the second bar is bigger than the first(get it right sometimes)).

The code above, which ensures that the third bar in the reversal closes higher than the high of the previous red bar, seems to not make use of the IsDoji and avgRange variables. What do they do?

Also, how would you write the bearish version of this? I tried the following but I don't think it works correctly:

Code:
plot bearish =  IsUp[3] and IsUp[2] and IsUp[1] and

IsDown[0] and low[1] > close[0];
 
Last edited:

BenTen

Administrative
Staff member
Staff
VIP
@DudeDastic You can actually use the built-in ThinkorSwim candlestick pattern builder to create your own version.

Click on Patterns > Select patterns > Candlestick >Create...

jdKSXMp.png
 

Similar threads

Top