"Candle State" Bar Type Identification :: TheStrat

R

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!



 
O

OBW

New member
@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);

 
R

radnor

New member
@OBW Thank you for the straightforward solution and rapid response!
 
  • Like
Reactions: OBW
A

ashfordtrader

New member
@OBW Can these number be a bit more lower? Reason is I use sequence counter and the numbers overlap.
 
M

Mandalorianknight63

New member
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.
 
MerryDay

MerryDay

Active member
VIP
@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);
 
M

Mandalorianknight63

New member
@MerryDay sweet, i was trying to look for that null or none value for after else where the original 2 went. thank you for that.
 
W

WalkThisWay

New member
@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.
 
M

modernmind

New member
@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?
 
W

WalkThisWay

New member
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?
 
G

Gator

New member
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
 
W

WalkThisWay

New member
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.
 
M

modernmind

New member
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.
 
W

WalkThisWay

New member
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?
 
M

modernmind

New member
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.
 
W

WalkThisWay

New member
This is my chart with time and price from today.



I am not running any other indicators, only a script with price levels.
 
Last edited by a moderator:
M

modernmind

New member
This is my chart with time and price from today.



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?
 
W

WalkThisWay

New member
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?
 
M

modernmind

New member
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.
 

Similar threads

Top