B3 Consolidation Box: Breakout / Breakdown Indicator for ThinkorSwim

tenacity11

tenacity11

Active member
2019 Donor
def Active = SecondsFromTime(0930) > 0 and SecondsTillTime(1000) >= 0; def ORBH = if Active and !Active[1] then high else if Active and high > ORBH[1] then high else ORBH[1]; plot scan = !Active and close > ORBH;
@tomsk Thanks so much. Will try this morning.
 
P

Playstation

Active member
VIP
Is it possible to strip the code until I'm left with just the grey consolidation box? Don't need any other lines.
 
T

tomsk

Well-known member
VIP
Is it possible to strip the code until I'm left with just the grey consolidation box? Don't need any other lines.

@Playstation As requested here is B3 Consolidation Box with all lines removed. Only the grey consolidation box remains
Load this study on a 5 minute chart of /ES and you 'll see all the consolidation boxes displayed

Code:
# Consolidation Box Barebones - with Grey Consolidation Box
# tomsk
# 11.23.2019

# As requested by Playstation, this is B3 Consolidation Box with all lines removed
# Only the grey consolidation box remains

# B3 Consolidation Box
# Hammond B3
# 2.2.2019

input BarsUsedForRange = 2;
input BarsRequiredToRemainInRange = 7;
input ColorPrice = yes;
input HideBoxLines = no;
input HideLabels = no;

# Identify Consolidation
def HH = highest(high[1], BarsUsedForRange);
def LL = lowest(low[1], BarsUsedForRange);
def maxH = highest(hh, BarsRequiredToRemainInRange);
def maxL = lowest(ll, BarsRequiredToRemainInRange);
def HHn = if maxH == maxH[1] or maxL == maxL then maxH else HHn[1];
def LLn = if maxH == maxH[1] or maxL == maxL then maxL else LLn[1];
def Bh = if high <= HHn and HHn == HHn[1] then HHn else double.nan;
def Bl = if low >= LLn and LLn == LLn[1] then LLn else double.nan;
def CountH = if isnan(Bh) or isnan(Bl) then 2 else CountH[1] + 1;
def CountL = if isnan(Bh) or isnan(Bl) then 2 else CountL[1] + 1;

def ExpH = if barnumber() == 1 then double.nan 
           else if CountH[-BarsRequiredToRemainInRange] >= BarsRequiredToRemainInRange then HHn[-BarsRequiredToRemainInRange] 
           else if High <= ExpH[1] then ExpH[1] 
           else double.nan;

def ExpL = if barnumber() == 1 then double.nan 
           else if Countl[-BarsRequiredToRemainInRange] >= BarsRequiredToRemainInRange then LLn[-BarsRequiredToRemainInRange] 
           else if Low >= ExpL[1] then ExpL[1] else double.nan;

# Plot the High and Low of the Box; Paint Cloud
plot BoxHigh = if !isnan(expL) and !isnan(ExpH) then ExpH else double.nan;
     boxhigh.setdefaultColor(color.dark_green);
     BoxHigh.setpaintingStrategy(paintingStrategy.HORIZONTAL);
     BoxHigh.SETHIDING(HideBoxLines);

plot BoxLow = if !isnan(expL) and !isnan(ExpH) then ExpL else double.nan;
     BoxLow.setpaintingStrategy(paintingStrategy.HORIZONTAL);
     BoxLow.setdefaultColor(color.dark_red);
     BoxLow.SETHIDING(HideBoxLines);

addcloud(BoxHigh, BoxLow, color.gray, color.gray);

# Things to the Right of a Finished Box
def eH = if barnumber() == 1 then double.nan else if !isnan(BoxHigh[1]) and isnan(BoxHigh) then BoxHigh[1] else eh[1];
def eL = if barnumber() == 1 then double.nan else if !isnan(BoxLow[1]) and isnan(BoxLow) then BoxLow[1] else el[1];

assignPriceColor(if !ColorPrice then color.current else if !isnan(BoxHigh) then color.gray else
                    if high > eh  and low < el then color.yellow else 
                    if high > eh then color.green else if low < el then color.red else color.gray);
# Consolidation Box Barebones
 
P

Playstation

Active member
VIP
@tomsk Oh my god you the man. Thank you. :giggle:
You even put my name inside the code!
 
T

tomsk

Well-known member
VIP
@tomsk Oh my god you the man. Thank you. :giggle:
You even put my name inside the code!

You're welcome, I placed some commentary so that there's some context as to why the lines disappeared in case someone else picks it up and requests it to be added back
 
P

Playstation

Active member
VIP
Touched 😭
Btw, it works on stocks too on lower time frame.

You're welcome, I placed some commentary so that there's some context as to why the lines disappeared in case someone else picks it up and requests it to be added back
 
M

Mindlessmentor

New member
for intraday scalp plays any recommended timeframe?
 
J

Johnny Cash

Member
VIP
Is it possible to change code to work on longer time frames such as daily 1 year chart or weekly 5 year charts?

I mean a scan for those time frames.
 
Last edited by a moderator:
H

hurricane5

New member
2019 Donor
1. Tried this indicator out today on ULTA...worked great! Took +60% in less than an hour.
2. A scanner for this would be gold (I did read that isn't possible though)! You have to manually look for the setup...that's how I found ULTA.
3. It works on mobile!!! You get everthing except the shaded grey box - but you do get the red and green consolidation boundaries.

I used TMO and RSI Leguerre to validate. Also added my MAs after the fact...
 
T

tomsk

Well-known member
VIP
1. Tried this indicator out today on ULTA...worked great! Took +60% in less than an hour.
2. A scanner for this would be gold (I did read that isn't possible though)! You have to manually look for the setup...that's how I found ULTA.
3. It works on mobile!!! You get everthing except the shaded grey box - but you do get the red and green consolidation boundaries.

I used TMO and RSI Leguerre to validate. Also added my MAs after the fact...


@hurricane5 The ECI sure is scannable, I previously converted that to be scannable. Here's the link

https://usethinkscript.com/threads/eci-gaussian-indicator-for-thinkorswim.1160/#post-10456
 
P

ProcrastinatingPerfection

New member
Hello BenTen,

Trying to find the B3 Consolidation Box code that could be used as a scan. Can't seem to find it, was wondering if you could help me with that please? I am new and still trying to find my way here. Thank you.
 
T

tomsk

Well-known member
VIP
I took a look at B3 Consolidation Box code. Unfortunately the way it is written when loaded into the scanner ran into complexity issues. The study works just fine on a chart with no issues
 
R

roger80k

New member
Can anyone help me find a script that will automatically draw box zones in the TOS. It will be used as the trading zone. Where I can input my risk level. Thanks
 
P

Playstation

Active member
VIP
I only use @tomsk adjusted code exclusively for identifying consolidation.
I would suggest the Opening range breakout indicator for further profit taking, works on ticks and time charts.
 
S

soary

Member
What is TMO? I only know T-Mobile as TMO but if referring to something else can someone enlghten me. Thanks
 

Similar threads

Top