Triple 3 Inside Bars Indicator and Scanner for ThinkorSwim


@leo2022 Thank you very much for creating and sharing your code. I added to my chart and created a watchlist. Added studies (TOS VWAP_scan and MovingAverage_Scan) for the price above vwap and 20 EMA greater than 5% within 20 periods for reliability no matter what pattern shows/ploted. Thank you again.

Good luck all!

cabe1332
 
Last edited:

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

So this is my first time posting in here. Just made my account so still getting familiar to all of this. I am a day trader that trades penny stocks and there was a custom candlestick pattern that I wanted to scan for. So I just went to the patterns place in TOS and made my own. Except I quickly noticed some stuff that weren't working out with just the basic options. So I was hoping to see if anybody could dive deeper into the thinkscript code to help me achieve what I'm striving for.

maxresdefault.jpg
This image is a baseline of something I'm looking for. Probably more of a red candle towards the middle body of the green candle but something like this.

I want to make the simple code I have and make it scan for stocks that have a greater than 20% move to the upside on that big candle. Then the red candle following that to be somewhere near half of the green candle move. This will show in the scans possible stocks that have potential to shoot upwards thus allowing us to use price action and volumetricsfor confirmation on the play.
Using the drop down for making my custom pattern I've achieved this code:

Code:
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
    low[1] < low[0] and
    open[1] <= close[0] and
    high[1] > high[0] and
    close[1] >= open[0];

PatternPlot.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
PatternPlot.SetDefaultColor(GetColor(4));

If anybody can help me solve this I will be very thankful. After all I believe this is a valuable pattern that more people should know about. If you have any questions lmk!!! Thank you for your time.
 
Your strategy is very similar to the 3 Bar Play strategy promoted by Live Traders. But he's picky about the little bar being close to the high of the big bar and he's not picky about the color of the little bar.


It's good you have pretty clear rules. You'll see in a second it's easy to turn each rule into code. You didn't mention any rule about the vertical position of the little bar compared to the big bar so this code allows it to be anywhere inside the range of the big bar.

Ruby:
def bigUp = close >= open * 1.2; # 20% increase
def range = high - low;
def small = range <= range[1] * .5; # half or less size of previous candle
def inside = high < high[1] and low > low[1];
def isDown = open > close;

plot PatternPlot = bigUp[1] and small and inside and isDown;
PatternPlot.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
PatternPlot.SetDefaultColor(GetColor(4));
 
WOW this is a masterpiece exactly how I wanted it. For example I have run the code and MDJH may pop again we'll see. About the vertical positioning I do not think it really matters just as long as it's towards the middle and not some stock that dropped crazy but I think you did great. 100/100
 
Respecting Jared's rules (I've followed him for a long time) The second bar shouldn't have much of a topping wick at all (if any) , and the bottom wick should not be more than 30% of the 1st bar. In other words, is there a way to restrict the script to literally make it look like the example picture? With maybe only a very small amount of "wick play"? the High of the 2nd candle being very close to the open and the low being very close to the close of the 2nd wick, with the close not being more than 30% of the 1st bar.... and the 3rd bar low not being any lower than the 2nd bar?

Thanks
 
I am trying to recreate the John Carter 3 bars. It's 3 bars the same color 3 red or 3 green, that create a reversal. I would like to create it with
AddChartBubble.
 
I want to backtest rallies.
Conditions I want to code.
1.) 3 lower lows, visually red bars have lower lows. Is 1st condition
2.) one of the bars. Not all bar has 300k volume. Just at least one of them. The 2nd condition
3.) Has to be at least 3 red bars to get tested; But no more than 7 bars. If it’s 8 bars it doesn’t get tested. Emphasis on at least one. Doesn’t have to be all of them. 3rd condition

4.) closes under 55ema. I don’t care if it’s the 3rd bar or 7th bar but one of the bars has to close below the 55ema. 4th condition this is the hardest one to me.

^^^^^ rally sequence code
Risk sequence code: 5.) opposite color from rally bar is risk, if it was a rally of red bars then this is the green bar. Green bar range let’s say it’s .80 cent. 500/.80 = 625. This uses the opposite color bar, open higher than close, as risk. Divide risk bar into $500 to know share size.

6.) add order code. Buy once cent above the high, sell once cent below the low. Stop loss code.

7.) exit code. 3r, 3 times risk, 3 times opposite color bar. Risk .80 I want $2.40 to be profit target so OCO order. One sell if it’s red bars, 2 buys once stop loss one cent below the low. One profit taking 3r from 1 cent above the high. If stop loss hit it cancels profit target. If profit target it cancels stop loss.

Code I have in theory but need help.
Def 3lowerlow = low < low[1] <low [2]
close < open and volume> 300000
Def green=close>open

Ema (close, 55, 0, no)
Def con ?

if anybody could help or just point me in the right direction it would be greatly appreciated. I’ve searched lower lows and everything everybody seems to be basing their backtesting off of moving averages and atr. I didn’t see a code looking for at least 3 lower lows, No more than 7.
 
hello and welcome. first, let me say, listing out your rules like that is a good start. but they have conflicting and missing information. they will have to be edited for people to help you.
if you edit your post, please put EDIT and a date , at the top.

my guesses on what you are looking for

1) 3 to 7 sequential red bars ( close < open) .and each low is lower than the previous bar low.
if 8+ then ignore.

2) any bar, or just the 2nd?
= 300k vol? <300k, > 300k?

one of the red bars has vol > 300k

3) 3 to 7 bars. merge this rule into rule 1

4) one of the red bars, close < ema55

5) rally. calc qty of shares to buy.
based off of a balance $ amount and the range of 1st green bar after the series of red bars. range = high - low.

6) which high? the last red bar , the first green bar?

7) too many conditions. since you have no code, i'm not going to think about this rule.
 
Last edited:
First, thank you for helping.

1.) Yes if 8 then ignore. But this is the at least 3 lower lows.
2.) any one of the (3 to 7 bars) must have 300k volume in a single bar
Correct: one of red bars > volume 300k
3.) rule #1 is 3 lower lows. Merge that with (need 3) (no more than 7)
4.) yes this is making sure one of them closes under the 55ema
5.) is correct as well
6.) buy once cent above the opposite color high so if 3 to 7 greens I buy once cent above the red.

I attached a picture to show the situation. Thank you for the assistance and patience, I’m new. Before 11am around 10 something, what I’m talking about happens.
 
Trying to make a red cloud when encounter 3 red bars in a a row. Something is wrong in my condition.
I get something like this.
https://drive.google.com/file/d/16qxkPWqDnsBHML5ipFsS5sIswOSGm3bN/view?usp=sharing

Image

def isRed3 = (close[2] < open[2]); # savoir si une bar est rouge ou verte.
def isRed2 = (close[1] < open[1]); # savoir si une bar est rouge ou verte.
def isRed = (close < open); # savoir si une bar est rouge ou verte.

def TroisRouges = (isRed3 == isRed2 == isRed);

AddCloud (if TroisRouges then OpenPrice else Double.NaN , ClosePrice, Color.Yellow, Color.RED, yes);
 
Trying to make a red cloud when encounter 3 red bars in a a row. Something is wrong in my condition.
I get something like this.
https://drive.google.com/file/d/16qxkPWqDnsBHML5ipFsS5sIswOSGm3bN/view?usp=sharing

Image

def isRed3 = (close[2] < open[2]); # savoir si une bar est rouge ou verte.
def isRed2 = (close[1] < open[1]); # savoir si une bar est rouge ou verte.
def isRed = (close < open); # savoir si une bar est rouge ou verte.

def TroisRouges = (isRed3 == isRed2 == isRed);

AddCloud (if TroisRouges then OpenPrice else Double.NaN , ClosePrice, Color.Yellow, Color.RED, yes);
the 'red' variables have boolean values, 1 or 0, true or false,...
combine them with logic: and, or

instead of this
def TroisRouges = (isRed3 == isRed2 == isRed);

try this
def TroisRouges = (isRed3 and isRed2 and isRed);
 
Hi, I imported this into my TOS using your shareable link above. Please remind me how to use this to create a scanner (as opposed to an indicator). Thanks!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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