"Candle State" Bar Type Identification :: TheStrat For ThinkOrSwim

radnor

New member
Is there a way to identify bars as either inside bar "1"; outside bar "3"; or directional bar "2" by placing a numerical identifier beneath each bar? SequenceCounter associates numbers with bars, but I did not see thinkscript for placing a numeral at individual bars.

Bar identification, together with higher timeframe trend recognition ("full timeframe continuity") is used for TheStrat concept by trader Rob Smith. The idea is that to play reversals/trends within broadening formations supported on larger timeframes.

This bar numbering question also came up in the thread for inside/outside bars: "Outside day and inside day scan"

There appears to be code for TradingView, but I did not see any thinkscript:
https://github.com/Crinklebine
Thanks!

7RFa3o7.jpg


mjIjhAg.jpg
 
Last edited by a moderator:
@radnor You can do it using the "values_below" painting strategy.
https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/PaintingStrategy
Python:
# +------------------------------------------------------------+
# |         Example code to print values below candles         |
# |                        Robert Payne                        |
# |               https://funwiththinkscript.com               |
# +------------------------------------------------------------+
def insideBar = high < high[1] and low > low[1];
def outsideBar = high > high[1] and low < low[1];
plot barType = if insideBar then 1 else if outsideBar then 3 else 2;
barType.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);

I8riU3e.png
 
awesome code.

is there anyway to take out the 2 from displaying and just making the code show 3's and 1's? I tried to modify but the code reads an error when i do.
 
@Mandalorianknight63
Code:
# +------------------------------------------------------------+
# |         Example code to print values below candles         |
# |                        Robert Payne                        |
# |               https://funwiththinkscript.com               |
# +------------------------------------------------------------+
def insideBar = high < high[1] and low > low[1];
def outsideBar = high > high[1] and low < low[1];
plot barType = if insideBar then 1 else if outsideBar then 3 else double.NaN;
barType.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
 
@Mandalorianknight63 @Pelonsax When I run this script I am getting 2's that should be 1's and 3's that should be 2's. Tried a few different versions of scripts to label the candles 1, 2, or3 for TheStrat and getting this same false reporting. This occurred several times in todays AAPL charting (9/8/2020) for 1 minute and 5 minute charts. Any ideas on what is causing this anomaly. Thanks, Walk.
 
@Mandalorianknight63 @Pelonsax When I run this script I am getting 2's that should be 1's and 3's that should be 2's. Tried a few different versions of scripts to label the candles 1, 2, or3 for TheStrat and getting this same false reporting. This occurred several times in todays AAPL charting (9/8/2020) for 1 minute and 5 minute charts. Any ideas on what is causing this anomaly. Thanks, Walk.
I just took a look at the 5 minute AAPL chart and didn't notice any anomalies. Any specific time of day that you noticed this?
 
At 12:47 pm there is a 3 that should be a 2 and at 12:54 pm there is a 2 that should be a 1. That is what my one minute chart shows. On the 5 min chart there is a 3 at 11:45 am that should be a 2 and there is a 2 at 12:50 that should be a 1. Do you see something different?
 
Hi. I looked at the candles you mentioned and the indicator Strat number was correct for all of them. At least they were on my TOS charts. Good luck
 
Hi. I looked at the candles you mentioned and the indicator Strat number was correct for all of them. At least they were on my TOS charts. Good luck
Thanks, was the number correct that I called out? Want to know if I should follow the numbers and not the bars. I tried this on different computers and different monitors and got the same bars/numbers as I posted.
 
At 12:47 pm there is a 3 that should be a 2 and at 12:54 pm there is a 2 that should be a 1. That is what my one minute chart shows. On the 5 min chart there is a 3 at 11:45 am that should be a 2 and there is a 2 at 12:50 that should be a 1. Do you see something different?
On the 5 minute chart: The candle at 11:45 on my chart is identified as a 2. The candle at 12:45 has a (high-113.72 / low-113.12). The candle at 12:50 has a (high-113.58 / low: 113.10) whose wick is lower than the candle at 12:45 and is correctly deemed a 2 in my opinion. I didn't look at the 1 minute chart.
 
On the 5 minute chart: The candle at 11:45 on my chart is identified as a 2. The candle at 12:45 has a (high-113.72 / low-113.12). The candle at 12:50 has a (high-113.58 / low: 113.10) whose wick is lower than the candle at 12:45 and is correctly deemed a 2 in my opinion. I didn't look at the 1 minute chart.
Are you using the code at the top of this post to get your numbers for the bars?
 
Are you using the code at the top of this post to get your numbers for the bars?
Affirmative. 1's and 3's only. It's possible that another active indicator on the chart is causing your corruption. Not saying it's certain but there is that possibility. It's happened to me before.
 
This is my chart with time and price from today.

BN1GtP8.png


I am not running any other indicators, only a script with price levels.
 
Last edited by a moderator:
This is my chart with time and price from today.

BN1GtP8.png


I am not running any other indicators, only a script with price levels.
Sorry, I'm on the west coast so my earlier post was incorrect regarding the time. I took a look at your chart above and your data is similar but doesn't quite match what I show. Am very curious now. Would like to know why your data looks different. Are you running "Candle trend" candles?
 
Sorry, I'm on the west coast so my earlier post was incorrect regarding the time. I took a look at your chart above and your data is similar but doesn't quite match what I show. Am very curious now. Would like to know why your data looks different. Are you running "Candle trend" candles?
I am running Heikin Ashi candles. Should I be using candle trend?
 
No, but that's why your candles look different. I'm not an expert but that's why your candles look different than mine. Shouldn't affect the high/low disparity I wouldn't think. My chart is using regular candles just for reference.
 

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