Tweezer candlestick pattern in ThinkorSwim

Buckbull

Active member
Is Anyone familiar with making your own candlestick pattern study ? Im trying to set up a bottoming tail on one study and a topping tail on another . Any pointers ?
 
Last edited by a moderator:
@Buckbull If you are not already aware you might like to know that TOS has a library of candlestick patterns available.
Just go to the TOS platform, click on charts. Then on the top right, there is a button called "Patterns"
There is a drop down menu, so you can go and explore that area. Many examples of chart of candlestick patterns there
 

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

@Buckbull If you want to create a more advanced candlestick pattern, you would have to write your own script for that. The default editor is still great for beginners to get started, though. Glad to hear about your tweezer top and bottom.
 
Ben Can you please check them out see if you would change anything I think they are good

Tweezer Top

Code:
# Generation time: 2020-12-09T00:55:57.031Z

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

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

Tweezer Bottom

Code:
# Generation time: 2020-12-09T00:56:49.012Z

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

PatternPlot.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
PatternPlot.SetDefaultColor(GetColor(0));
 
Last edited by a moderator:
Im trying to do something like this the doesnt have to be a Super Bottoming tail but something with a small body and a long tail
superbottomingtail1.png
 
@tomsk Could you by any chance help me out , with the pinbar study ben posted i would like to do a scan where the pinbar closes within the body of the previous days candle . Thanks

@Buckbull - I assume you're referring to the Pinbar indicator that @BenTen posted in the following thread

https://usethinkscript.com/threads/pin-bar-reversal-indicator-for-thinkorswim.156/
Here is your COMPLETED scan. Load the following code directly into the scanner. It scans for a bullish/bearish pinbar that closes within the body of the previous days candle. Please note that I have NOT changed any of the definitions of the pinbar definition that came with the original study
I just added your requirement for closes within the body of the previous candle and some minor clean up to enable the scan.

I have tested the scan on the S&P 500. At the present time, a bullish scan yields 2 results while a bearish scan yields 1 result.

Code:
# Pinbar Scan
# tomsk
# 11.23.2019
# https://usethinkscript.com/threads/create-your-own-candlestick-pattern-in-thinkorswim.1103/#post-10213

# This scans for a bullish/bearish pinbar that closes within the body 
# of the previous candle. The conditions for the logic for the pinbar 
# conditions were extracted from the following study as posted by BenTen 
# in May 2019
#
# https://usethinkscript.com/threads/pin-bar-reversal-indicator-for-thinkorswim.156/

input LastBars = 0;
input MaxNoseBodySize = 0.33; #(default = 0.33) — maximum allowed body/length ratio for the Nose bar.
input NoseBodyPosition = 0.4; #(default = 0.4) — Nose body should be position in top (bottom for bearish pattern) part of the Nose bar.
input LeftEyeOppositeDirection = yes; #(default = true) — tells the indicator that the Left Eye bar should be bearish for bullish Pinbar, and bullish for bearish Pinbar.
input NoseSameDirection = yes; #(default = true) — tells the indicator that the Nose bar should be of the same direction as the pattern itself.
input NoseBodyInsideLeftEyeBody = no; #(default = false) — tells the indicator that the Nose body should be inside the Left Eye body.
input LeftEyeMinBodySize = 0.1; #(default = 0.1) — minimum size of the Left Eye body relative to the bar length.
input NoseProtruding = 0.5; #(default = 0.5) — minimum protrusion of the Nose bar relative to the bar length.
input NoseBodyToLeftEyeBody = 1; #(default = 1) — maximum size of the Nose body relative to the Left eye body.
input NoseLengthToLeftEyeLength = 0; #(default = 0) — minimum Nose length relative to the Left Eye length.
input LeftEyeDepth = 0.2; #(default = 0.2) — minimum depth of the Left Eye relative to its length. Depth is length of the part of the bar behind the Nose.

# Left Eye and Nose bars's paramaters
def NoseLength = High - Low;
def LeftEyeLength = High[1] - Low[1];
def NoseBody = Absvalue(Open - Close);
def LeftEyeBody = Absvalue(Open[1] - Close[1]);

# Bearish Pinbar

def BearSignalDown = if  (High - High[1] >= NoseLength * NoseProtruding) and
                     (NoseBody / NoseLength <= MaxNoseBodySize) and
                     (1 - (High - Max(Open, Close)) / NoseLength < NoseBodyPosition) and
                     if LeftEyeOppositeDirection then (Close[1] > Open[1]) else 1 and
                     if NoseSameDirection then (Close < Open) else 1  and
                     (LeftEyeBody / LeftEyeLength  >= LeftEyeMinBodySize) and
                     ((Max(Open, Close) <= High[1]) && (Min(Open, Close) >= Low[1]))  and
                     (NoseBody / LeftEyeBody <= NoseBodyToLeftEyeBody) and
                     (NoseLength / LeftEyeLength >= NoseLengthToLeftEyeLength) and
                     (Low - Low[1] >= LeftEyeLength * LeftEyeDepth) and
                     if NoseBodyInsideLeftEyeBody then ((Max(Open, Close) <= Max(Open[1], Close[1]))
                     && (Min(Open,  Close) >= Min(Open[1],  Close[1]))) else 1                   
                     then yes
                     else no ;

def BullSignalUp   = if (Low[1] - Low >= NoseLength * NoseProtruding) and
                     (NoseBody / NoseLength <= MaxNoseBodySize) and
                     (1 - (Min(Open, Close) - Low) / NoseLength < NoseBodyPosition) and
                     if LeftEyeOppositeDirection then (Close[1] < Open[1]) else 1 and
                     if NoseSameDirection then (Close > Open) else 1 and
                     (LeftEyeBody / LeftEyeLength >= LeftEyeMinBodySize) and
                     ((Max(Open, Close) <= High[1]) && (Min(Open, Close) >= Low[1])) and
                     (NoseBody / LeftEyeBody <= NoseBodyToLeftEyeBody) and
                     (NoseLength / LeftEyeLength >= NoseLengthToLeftEyeLength) and
                     (High[1] - High >= LeftEyeLength * LeftEyeDepth) and
                     if NoseBodyInsideLeftEyeBody then ((Max(Open, Close) <= Max(Open[1], Close[1]))
                     && (Min(Open, Close) >= Min(Open[1], Close[1]))) else 1
                     then yes
                     else no;

# Scan specific logic. Look for a close within previous bar's body
# Add this to the original scan condition from a user request

def condition = between(close, min(open[1],close[1]),max(open[1],close[1]));

# Comment out (#) the ONE not needed

plot bullish_signal = BullSignalup and condition;
# plot bearish_signal = BearSignalDown and condition;

# End Pinbar Scan
 
Last edited:
Awesome thanks as usual , But Im a little confused if im saving it right when I copied the script you made in I got 2 stocks like you did
$REG
$MKC
How do I switch it to a Bearish Scan ?
 
Bullish scan

# Comment out (#) the ONE not needed

plot bullish_signal = BullSignalup and condition;
# plot bearish_signal = BearSignalDown and condition;

# End Pinbar Scan

Bearish Scan

# Comment out (#) the ONE not needed

# plot bullish_signal = BullSignalup and condition;
plot bearish_signal = BearSignalDown and condition;

# End Pinbar Scan

I would just save as different scans.
 
Awesome thanks as usual , But Im a little confused if im saving it right when I copied the script you made in I got 2 stocks like you did
$REG
$MKC
How do I switch it to a Bearish Scan ?

You seem to be new to scans - please note that the scanner only accepts one plot statement
I have listed two in the code, one commented out. Just switch those round for theopposite case

You should get 1 result for the bearish case if you ran the scan today
 
Last edited:
Hi, looking for two consecutive green candles script & two consecutive red candles script.
Can someone help?

Thank you
Daniel.

Very easy to do using the TOS candlestick pattern editor.

Here is an example:

q7XOnCI.png


Two consecutive green candles.

Code:
# Generation time: 2021-05-06T02:20:32.449444600Z

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

PatternPlot.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
PatternPlot.SetDefaultColor(GetColor(0));
 
@Buckbull I thought a tweezer top or bottom happens in a trend. Do your studies include this?
And be aware a tweezer can also be a trend continuation signal I believe approximately half the time.
Hope my memory is not betraying me on this.
 
Tweezer Top

Code:
# Generation time: 2020-12-09T00:55:57.031Z

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

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

Tweezer Bottom

Code:
# Generation time: 2020-12-09T00:56:49.012Z

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

PatternPlot.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
PatternPlot.SetDefaultColor(GetColor(0));
Can you post a picture of what this is supposed to look like when it finds one please?
 
Very easy to do using the TOS candlestick pattern editor.

Here is an example:

q7XOnCI.png


Two consecutive green candles.

Code:
# Generation time: 2021-05-06T02:20:32.449444600Z

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

PatternPlot.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
PatternPlot.SetDefaultColor(GetColor(0));
Thanks so much!!!
 
Thread starter Similar threads Forum Replies Date
T 8ema candlestick pattern Questions 3
T Long Candlestick Questions 3
Hannah Candlestick Pattern Alert Questions 1
TickTockTony Pin Bar candlestick code Questions 2
B candlestick upper indicator Questions 3

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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