Bill Williams Green, Squat, Fade, Fake Bars and Zone Bars for ThinkorSwim

henry1224

Expert
VIP
Lifetime
Code:
#From the book New Trading Dimensions by Bill Willams, PhD
#Coded by Henry Z Kaczmarczyk 01/2021
#Added Multiple Time Frame
#Added "AssignPriceColor"  apc input "to turn off set number to 0 or 4"
#ZoneBars are lines 1 thru 3 "Points"
#Green , Squat, Fade, Fake bars are lines 5 thru 7 "Squares"
#Lower time frames are on the bottom ,higher time frames are on top
Declare Lower;
DefineGlobalColor("GreenZone",Color.Green);
DefineGlobalColor("RedZone",Color.Red);
DefineGlobalColor("Neutral",Color.Blue);
DefineGlobalColor("Greenbar", Color.Green);
DefineGlobalColor("Squatbar", Color.Blue);
DefineGlobalColor("Fadebar", Color.Red);
DefineGlobalColor("Fakebar", Color.Orange);
DefineGlobalColor("Zero", Color.Gray);
input agg1 = AggregationPeriod.FIVE_MIN;
input agg2 = AggregationPeriod.THIRTY_MIN;
input agg3 = AggregationPeriod.HOUR;
Input apc = 5;
Input DotSize = 3;
Def Price1 = HL2(Period = agg1);
Def Price2 = HL2(Period = agg2);
Def Price3 = HL2(Period = agg3);
Def Vol1 = Volume(Period = agg1);
Def Vol2 = Volume(Period = agg2);
Def Vol3 = Volume(Period = agg3);
Def H1 = High(Period = agg1);
Def H2 = High(Period = agg2);
Def H3 = High(Period = agg3);
Def L1 = Low(Period = agg1);
Def L2 = Low(Period = agg2);
Def L3 = Low(Period = agg3);
def AO1 = Average(Price1,5) - Average(Price1,34);
def AO2 = Average(Price2,5) - Average(Price2,34);
def AO3 = Average(Price3,5) - Average(Price3,34);
def AC1 = AO1 - Average(AO1,5);
def AC2 = AO2 - Average(AO2,5);
def AC3 = AO3 - Average(AO3,5);
def GZone1 = if AO1 > AO1[1] and AC1 > AC1[1] then 1 else 0;
def RZone1 = if AO1 < AO1[1] and AC1 < AC1[1] then 1 else 0;
def GZone2 = if AO2 > AO2[1] and AC2 > AC2[1] then 1 else 0;
def RZone2 = if AO2 < AO2[1] and AC2 < AC2[1] then 1 else 0;
def GZone3 = if AO3 > AO3[1] and AC3 > AC3[1] then 1 else 0;
def RZone3 = if AO3 < AO3[1] and AC3 < AC3[1] then 1 else 0;
def mfiA = if Vol1 > 0 then (H1 – L1) / Vol1 * 100 else 0;
def mfiB = if Vol2 > 0 then (H2 – L2) / Vol2 * 100 else 0;
def mfiC = if Vol3 > 0 then (H3 – L3) / Vol3 * 100 else 0;
def Con1A = if Vol1[1] > Vol1[2] then 1 else 0;
def Con2A = if mfiA[1] > mfiA[2] then 1 else 0;
def Con1B = if Vol2[1] > Vol2[2] then 1 else 0;
def Con2B = if mfiB[1] > mfiB[2] then 1 else 0;
def Con1C = if Vol3[1] > Vol3[2] then 1 else 0;
def Con2C = if mfiC[1] > mfiC[2] then 1 else 0;
def BW1a= if Con1A == 1 and Con2A == 1 then 1 else 0;
def BW2a= if Con1A == 1 and Con2A == 0 then 2 else 0;
def BW3a= if Con1A == 0 and Con2A == 0 then 3 else 0;
def BW4a= if Con1A == 0 and Con2A == 1 then 4 else 0;
def SBa = (BW1a + BW2a + BW3a + BW4a);
def BW1b= if Con1B == 1 and Con2B == 1 then 1 else 0;
def BW2b= if Con1B == 1 and Con2B == 0 then 2 else 0;
def BW3b= if Con1B == 0 and Con2B == 0 then 3 else 0;
def BW4b= if Con1B == 0 and Con2B == 1 then 4 else 0;
def SBb = (BW1b + BW2b + BW3b + BW4b);
def BW1c= if Con1C == 1 and Con2C == 1 then 1 else 0;
def BW2c= if Con1C == 1 and Con2C == 0 then 2 else 0;
def BW3c= if Con1C == 0 and Con2C == 0 then 3 else 0;
def BW4c= if Con1C == 0 and Con2C == 1 then 4 else 0;
def SBc = (BW1c + BW2c + BW3c + BW4c);

Plot Dot1 = 1;
Dot1.SetpaintingStrategy(PaintingStrategy.Points);
Dot1.SetLineWeight(DotSize);
Dot1.AssignValueColor( if GZone1 == 1 then GlobalColor("GreenZone") else if RZone1 == 1 then GlobalColor("RedZone") else GlobalColor("Neutral"));
Plot Dot2 = 2;
Dot2.SetpaintingStrategy(PaintingStrategy.Points);
Dot2.SetLineWeight(DotSize);
Dot2.AssignValueColor( if GZone2 == 1 then GlobalColor("GreenZone") else if RZone2 == 1 then GlobalColor("RedZone") else GlobalColor("Neutral"));
Plot Dot3 = 3;
Dot3.SetpaintingStrategy(PaintingStrategy.Points);
Dot3.SetLineWeight(DotSize);
Dot3.AssignValueColor( if GZone3 == 1 then GlobalColor("GreenZone") else if RZone3 == 1 then GlobalColor("RedZone") else GlobalColor("Neutral"));
Plot Dot5 =5;
Dot5.SetpaintingStrategy(PaintingStrategy.Squares);
Dot5.SetLineWeight(3);
Dot5.assignValueColor(if SBa == 1 then GlobalColor("Greenbar") else if SBa == 2 then GlobalColor("Squatbar") else if SBa == 3 then GlobalColor("Fadebar") else if SBa == 4 then GlobalColor("Fakebar") else GlobalColor("Zero"));
Plot Dot6 =6;
Dot6.SetpaintingStrategy(PaintingStrategy.Squares);
Dot6.SetLineWeight(4);
Dot6.assignValueColor(if SBb == 1 then GlobalColor("Greenbar") else if SBb == 2 then GlobalColor("Squatbar") else if SBb == 3 then GlobalColor("Fadebar") else if SBb == 4 then GlobalColor("Fakebar") else GlobalColor("Zero"));
Plot Dot7 =7;
Dot7.SetpaintingStrategy(PaintingStrategy.Squares);
Dot7.SetLineWeight(5);
Dot7.assignValueColor(if SBc == 1 then GlobalColor("Greenbar") else if SBc == 2 then GlobalColor("Squatbar") else if SBc == 3 then GlobalColor("Fadebar") else if SBc == 4 then GlobalColor("Fakebar") else GlobalColor("Zero"));

AssignPriceColor( if apc == 1 and GZone1 == 1 then GlobalColor("GreenZone") else if apc == 1 and RZone1 == 1 then GlobalColor("RedZone") else if apc ==1 and GZone1 == 0 and RZone1 == 0 then GlobalColor("Neutral") else if apc == 2 and GZone2 == 1 then GlobalColor("GreenZone") else if apc == 2 and RZone2 == 1 then GlobalColor("RedZone") else if apc == 2 and Gzone2 ==0 and RZone2 == 0 then GlobalColor("Neutral") else if apc == 3 and GZone3 == 1 then GlobalColor("GreenZone") else if  apc == 3 and RZone3 == 1 then GlobalColor("RedZone") else if apc == 3 and Gzone3 ==0 and RZone3 ==0 then GlobalColor("Neutral") else if apc == 5 and SBa == 1 then GlobalColor(“Greenbar”) else if APC == 5 and SBa == 2 then GlobalColor(“Squatbar”) else if apc == 5 and SBa == 3 then GlobalColor(“Fadebar”) else if apc == 5 and SBa == 4 then GlobalColor(“Fakebar”) else if apc == 6 and SBb == 1 then GlobalColor(“Greenbar”) else if APC == 6 and SBb == 2 then GlobalColor(“Squatbar”) else if apc == 6 and SBb == 3 then GlobalColor(“Fadebar”) else if apc == 6 and SBb == 4 then GlobalColor(“Fakebar”)else if apc == 7 and SBc == 1 then GlobalColor(“Greenbar”) else if APC == 7 and SBc == 2 then GlobalColor(“Squatbar”) else if apc == 7 and SBc == 3 then GlobalColor(“Fadebar”) else if apc ==7 and SBc == 4 then GlobalColor(“Fakebar”)else Color.current);
 

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

just did a little digging haha


a blue squat bar according to the book occurs within 3 bars of a top or bottom , a green bar shows momentum, a red Fade bar shows bearishness, a yellow bars shows a false move.
A green zone shows when the AO oscilator & the Accel/decel indicator are both bullish, while the Red zone shows when they are both bearish

this is done on 3 different time frames, with the lowest time frame on the bottom and higher time frames above
 
Last edited:
Here is a version that combines the following indicators "Trend Advisor Diamond Phase", "Tea v2.0" , "Bill Williams Zone Bars" , & "Bill Williams SquatBars"
The documentation is included in the formula
All Indicators have Assign Price Color & 3_MTF's

Code:
#From the book New Trading Dimensions by Bill Willams, PhD
#Coded by Henry Z Kaczmarczyk 01/2021
#Added Multiple Time Frame
# TEA 2.0 - TOS version - 2015-06-04
# From Andrew Falde's work - LessThanRandom.com
# Converted from TradeStation to TOS by John Chernicky
#Hint: TEA 2.0 by Andrew Falde at LessThanRandom.com
#Trend Advisor Diamond Phase by Chuck Dukas , Coded by Henry Z Kaczmarczyk
#Trend Advisor Line 1 is current Time Frame. Line 2 is next higher Time Frame. Line 3 is second higher time frame.
#Trend Advisor is shown as Squares Compares Close to the 50 & 200 SMA
#Recovery Phase is Light Green
#Warning Phase is Orange
#Accumulation Phase is Green
#Dispersition Phase is Red
#Bullish Phase is Dark_Green
#Bearish Phase is Dark_Red
#TEA v 2.0 are shown as Points on lines 0,5 TEAB First Higher Time frame Lines 6, TEAC secondsFromTime higher Time frame Lines 7
#Consolidation is shown as Blue Points on the zero line
# Trend Caclulation
# 1 - Accumulation color Dark_Red
# 2 - Mark Up Color Green
# 3 - Distribution Color Dark_Green
# 4 - Mark Down Color Red
# 0 - No Trend
# Bill Williams Zone Bars are shown as Triangles in 3 Different Time Frames
#Green Triangles show when the Awesome Oscillator & Acceleration Osc are Bullish
#Red Triangles show when the Awesome Oscillator & Acceleration Osc are Bearish
#Blue Triangles show when the Awesome Oscillator & Acceleration Osc are Neutral
#Line 9 is then current Time Frame, Line 10 is then next higher time frame, Line 11 is the second higher Time Frame
#SquatBars are shown as Squares on Lines 13,14,15. Line 10 is the currentRatio Time Frame, Line 13 is the next Higher Time Frame, Line 14 is the secondsFromTime Higher Time Frame.
#GreenBars are green and are Bullish
#Squat Bars are Blue and show trend reversal at the end of Trends
#Fade Bars are Red and are Bearish
#FakeBars are Orange
#APC = 1 thru 3 will paint bars for Trend Advisor
#APC = 5 thru 7 will paint bars for TEA v2.0
#APC = 9 thru 11 will paint bars for Zone Bars
#APC = 13 thru 15 will Paint Bars for Squat Bars
Declare Lower;
DefineGlobalColor("GreenZone",Color.Green);
DefineGlobalColor("RedZone",Color.Red);
DefineGlobalColor("Neutral",Color.Blue);
DefineGlobalColor("Greenbar", Color.Green);
DefineGlobalColor("Squatbar", Color.Blue);
DefineGlobalColor("Fadebar", Color.Red);
DefineGlobalColor("Fakebar", Color.Orange);
DefineGlobalColor("Zero", Color.Gray);
input agg1 = AggregationPeriod.FIVE_MIN;
input agg2 = AggregationPeriod.THIRTY_MIN;
input agg3 = AggregationPeriod.HOUR;
Input apc = 5;
Input DotSize = 3;
Input Length1 = 50;
Input Length2 = 200;
input Period = 21; # Bars for Price Analysis TEA
Def Price1 = HL2(Period = agg1);
Def Price2 = HL2(Period = agg2);
Def Price3 = HL2(Period = agg3);
Def Vol1 = Volume(Period = agg1);
Def Vol2 = Volume(Period = agg2);
Def Vol3 = Volume(Period = agg3);
Def H1 = High(Period = agg1);
Def H2 = High(Period = agg2);
Def H3 = High(Period = agg3);
Def L1 = Low(Period = agg1);
Def L2 = Low(Period = agg2);
Def L3 = Low(Period = agg3);
Def C1 = Close(Period = agg1);
Def C2 = Close(Period = agg2);
Def C3 = Close(Period = agg3);

Def ML1=Average(C1,Length1);
Def ML2=Average(C1,Length2);
Def BML1=Average(C2,Length1);
Def BML2=Average(C2,Length2);
Def CML1=Average(C3,Length1);
Def CML2=Average(C3,Length2);
Plot RecP = If (ML1 < ML2 AND C1 < ML2 AND C1 > ML1) then 1 else Double.Nan;
Plot WarnP = If(ML1 > ML2 AND C1 > ML2 AND C1 < ML1) then 1 Else Double.Nan;
Plot AcumP = If(ML1 < ML2 AND C1 > ML2 AND C1 > ML1) Then 1 Else Double.Nan;
Plot DispP = If(ML1 > ML2 AND C1 < ML2 AND C1 < ML1) then 1 else Double.Nan;
Plot BullP = If(ML1 > ML2 AND C1 > ML2 AND C1 > ML1) then 1 else Double.Nan;
Plot BearP = If(ML1 < ML2 AND C1 < ML2 AND C1 < ML1) then 1 else Double.Nan;
RecP.SetPaintingStrategy(PaintingStrategy.Squares);
RecP.SetDefaultColor(Color.Light_Green);
RecP.SetLineWeight(DotSize);
WarnP.SetPaintingStrategy(PaintingStrategy.Squares);
WarnP.SetDefaultColor(Color.Orange);
WarnP.SetLineWeight(DotSize);
AcumP.SetPaintingStrategy(PaintingStrategy.Squares);
AcumP.SetDefaultColor(Color. Green);
AcumP.SetLineWeight(DotSize);
DispP.SetPaintingStrategy(PaintingStrategy.Squares);
DispP.SetDefaultColor(Color.Red);
DispP.SetLineWeight(DotSize);
BullP.SetPaintingStrategy(PaintingStrategy.Squares);
BullP.SetDefaultColor(Color.Dark_Green);
BullP.SetLineWeight(DotSize);
BearP.SetPaintingStrategy(PaintingStrategy.Squares);
BearP.SetDefaultColor(Color.Dark_Red);
BearP.SetLineWeight(DotSize);

Plot RecPB = If (BML1 < BML2 AND C2 < BML2 AND C2 > BML1) then 2 else Double.Nan;
Plot WarnPB = If(BML1 > BML2 AND C2 > BML2 AND C2 < BML1) then 2 Else Double.Nan;
Plot AcumPB = If(BML1 < BML2 AND C2 > BML2 AND C2 > BML1) Then 2 Else Double.Nan;
Plot DispPB = If(BML1 > BML2 AND C2 < BML2 AND C2 < BML1) then 2 else Double.Nan;
Plot BullPB = If(BML1 > BML2 AND C2 > BML2 AND C2 > BML1) then 2 else Double.Nan;
Plot BearPB = If(BML1 < BML2 AND C2 < BML2 AND C2 < BML1) then 2 else Double.Nan;
RecPB.SetPaintingStrategy(PaintingStrategy.Squares);
RecPB.SetDefaultColor(Color.Light_Green);
RecPB.SetLineWeight(DotSize);
WarnPB.SetPaintingStrategy(PaintingStrategy.Squares);
WarnPB.SetDefaultColor(Color.Orange);
WarnPB.SetLineWeight(DotSize);
AcumPB.SetPaintingStrategy(PaintingStrategy.Squares);
AcumPB.SetDefaultColor(Color. Green);
AcumPB.SetLineWeight(DotSize);
DispPB.SetPaintingStrategy(PaintingStrategy.Squares);
DispPB.SetDefaultColor(Color.Red);
DispPB.SetLineWeight(DotSize);
BullPB.SetPaintingStrategy(PaintingStrategy.Squares);
BullPB.SetDefaultColor(Color.Dark_Green);
BullPB.SetLineWeight(DotSize);
BearPB.SetPaintingStrategy(PaintingStrategy.Squares);
BearPB.SetDefaultColor(Color.Dark_Red);
BearPb.SetLineWeight(DotSize);

Plot RecPC = If (CML1 < CML2 AND C3 < CML2 AND C3 > CML1) then 3 else Double.Nan;
Plot WarnPC = If(CML1 > CML2 AND C3 > BML2 AND C3 < CML1) then 3 Else Double.Nan;
Plot AcumPC = If(CML1 < CML2 AND C3 > BML2 AND C3 > CML1) Then 3 Else Double.Nan;
Plot DispPC = If(CML1 > CML2 AND C3 < BML2 AND C3 < CML1) then 3 else Double.Nan;
Plot BullPC = If(CML1 > CML2 AND C3 > BML2 AND C3 > CML1) then 3 else Double.Nan;
Plot BearPC = If(CML1 < CML2 AND C3 < BML2 AND C3 < CML1) then 3 else Double.Nan;
RecPC.SetPaintingStrategy(PaintingStrategy.Squares);
RecPC.SetDefaultColor(Color.Light_Green);
RecPC.SetLineWeight(DotSize);
WarnPC.SetPaintingStrategy(PaintingStrategy.Squares);
WarnPC.SetDefaultColor(Color.Orange);
WarnPC.SetLineWeight(DotSize);
AcumPC.SetPaintingStrategy(PaintingStrategy.Squares);
AcumPC.SetDefaultColor(Color. Green);
AcumPc.SetLineWeight(DotSize);
DispPC.SetPaintingStrategy(PaintingStrategy.Squares);
DispPC.SetDefaultColor(Color.Red);
DispPC.SetLineWeight(DotSize);
BullPC.SetPaintingStrategy(PaintingStrategy.Squares);
BullPC.SetDefaultColor(Color.Dark_Green);
BullPC.SetLineWeight(DotSize);
BearPC.SetPaintingStrategy(PaintingStrategy.Squares);
BearPC.SetDefaultColor(Color.Dark_Red);
BearPC.SetLineWeight(DotSize);
Plot Zeroline=0;
ZeroLine.SetDefaultColor(GetColor(7));
# Expansion Calculation
def ATR = reference ATR(Period, averageType = AverageType.SIMPLE);
def StdDev = StDev(data = Close, length = Period);
def squeeze = (ATR * .75) - StdDev;
def Expansion = If (squeeze < 0, 1, 0);

# Linear Regression

def lowest = Lowest(L1[1], Period);
def lowestB = Lowest(L2[1], Period);
def lowestC = Lowest(L3[1], Period);
def highest = Highest(H1[1], Period);
def highestB = Highest(H2[1], Period);
def highestC = Highest(H3[1], Period);
def EMA = ExpAverage(C1, Period);
def EMAB = ExpAverage(C2, Period);
def EMAC = ExpAverage(C3, Period);
def Resolve = C1 - ((highest + lowest) / 2 + EMA) / 2;
def ResolveB = C2 - ((highestB + lowestB) / 2 + EMAB) / 2;
def ResolveC = C3 - ((highestC + lowestC) / 2 + EMAC) / 2;
def Trendline = LinearRegCurve(0, Period, Resolve);
def TrendlineB = LinearRegCurve(0, Period, ResolveB);
def TrendlineC = LinearRegCurve(0, Period, ResolveC);

# Trend Caclulation
# 1 - Accumulation
# 2 - Mark Up
# 3 - Distribution
# 4 - Mark Down
# 0 - No Trend
def Trend = if Trendline <= 0 and Trendline > Trendline[1] then 1 else (
            if Trendline > 0 and Trendline > Trendline[1] then 2 else (
            if Trendline > 0 and Trendline < Trendline[1] then 3 else (
            if Trendline <= 0 and Trendline < Trendline[1] then 4 else (
            Double.NaN))));
def TrendB = if TrendlineB <= 0 and TrendlineB > TrendlineB[1] then 1 else (
            if TrendlineB > 0 and TrendlineB > TrendlineB[1] then 2 else (
            if TrendlineB > 0 and TrendlineB < TrendlineB[1] then 3 else (
            if TrendlineB <= 0 and TrendlineB < TrendlineB[1] then 4 else (
            Double.NaN))));
def TrendC = if TrendlineC <= 0 and TrendlineC > TrendlineC[1] then 1 else (
            if TrendlineC > 0 and TrendlineC > TrendlineC[1] then 2 else (
            if TrendlineC > 0 and TrendlineC < TrendlineC[1] then 3 else (
            if TrendlineC <= 0 and TrendlineC < TrendlineC[1] then 4 else (
            Double.NaN))));

plot TEA =
(if Trend == 1 then 5
else (if Trend == 2 then 5
else (if Trend == 3 then 5
else (if Trend == 4 then 5 else Double.NaN
))));

plot TEAB =
(if TrendB == 1 then 6
else (if TrendB == 2 then 6
else (if TrendB == 3 then 6
else (if TrendB == 4 then 6 else Double.NaN
))));

plot TEAC =
(if TrendC == 1 then 7
else (if TrendC == 2 then 7
else (if TrendC == 3 then 7
else (if TrendC == 4 then 7 else Double.NaN
))));

plot Consolidated = (if Expansion == 0 then 0 else Double.NaN);

TEA.AssignValueColor
(if Trend == 1 then Color.DARK_RED
else (if Trend == 2 then Color.GREEN
else (if Trend == 3 then Color.DARK_GREEN
else (if Trend == 4 then Color.RED else Color.DARK_GRAY
))));

TEA.SetPaintingStrategy(PaintingStrategy.POINTS);
TEA.SetLineWeight(4);
#TEA.HideTitle();
TEA.HideBubble();

TEAB.AssignValueColor
(if TrendB == 1 then Color.DARK_RED
else (if TrendB == 2 then Color.GREEN
else (if TrendB == 3 then Color.DARK_GREEN
else (if TrendB == 4 then Color.RED else Color.DARK_GRAY
))));

TEAB.SetPaintingStrategy(PaintingStrategy.POINTS);
TEAB.SetLineWeight(4);
#TEAB.HideTitle();
TEAB.HideBubble();

TEAC.AssignValueColor
(if TrendC == 1 then Color.DARK_RED
else (if TrendC == 2 then Color.GREEN
else (if TrendC == 3 then Color.DARK_GREEN
else (if TrendC == 4 then Color.RED else Color.DARK_GRAY
))));

TEAC.SetPaintingStrategy(PaintingStrategy.POINTS);
TEAC.SetLineWeight(4);
#TEAC.HideTitle();
TEAC.HideBubble();

Consolidated.AssignValueColor(Color.BLUE);
Consolidated.SetPaintingStrategy(PaintingStrategy.POINTS);
Consolidated.SetLineWeight(4);
#Consolidated.HideTitle();
Consolidated.HideBubble();
#AddLabel(yes, "LessThanRandom.com", Color.GRAY);

def AO1 = Average(Price1,5) - Average(Price1,34);
def AO2 = Average(Price2,5) - Average(Price2,34);
def AO3 = Average(Price3,5) - Average(Price3,34);
def AC1 = AO1 - Average(AO1,5);
def AC2 = AO2 - Average(AO2,5);
def AC3 = AO3 - Average(AO3,5);
def GZone1 = if AO1 > AO1[1] and AC1 > AC1[1] then 1 else 0;
def RZone1 = if AO1 < AO1[1] and AC1 < AC1[1] then 1 else 0;
def GZone2 = if AO2 > AO2[1] and AC2 > AC2[1] then 1 else 0;
def RZone2 = if AO2 < AO2[1] and AC2 < AC2[1] then 1 else 0;
def GZone3 = if AO3 > AO3[1] and AC3 > AC3[1] then 1 else 0;
def RZone3 = if AO3 < AO3[1] and AC3 < AC3[1] then 1 else 0;
def mfiA = if Vol1 > 0 then (H1 – L1) / Vol1 * 100 else 0;
def mfiB = if Vol2 > 0 then (H2 – L2) / Vol2 * 100 else 0;
def mfiC = if Vol3 > 0 then (H3 – L3) / Vol3 * 100 else 0;
def Con1A = if Vol1[1] > Vol1[2] then 1 else 0;
def Con2A = if mfiA[1] > mfiA[2] then 1 else 0;
def Con1B = if Vol2[1] > Vol2[2] then 1 else 0;
def Con2B = if mfiB[1] > mfiB[2] then 1 else 0;
def Con1C = if Vol3[1] > Vol3[2] then 1 else 0;
def Con2C = if mfiC[1] > mfiC[2] then 1 else 0;
def BW1a= if Con1A == 1 and Con2A == 1 then 1 else 0;
def BW2a= if Con1A == 1 and Con2A == 0 then 2 else 0;
def BW3a= if Con1A == 0 and Con2A == 0 then 3 else 0;
def BW4a= if Con1A == 0 and Con2A == 1 then 4 else 0;
def SBa = (BW1a + BW2a + BW3a + BW4a);
def BW1b= if Con1B == 1 and Con2B == 1 then 1 else 0;
def BW2b= if Con1B == 1 and Con2B == 0 then 2 else 0;
def BW3b= if Con1B == 0 and Con2B == 0 then 3 else 0;
def BW4b= if Con1B == 0 and Con2B == 1 then 4 else 0;
def SBb = (BW1b + BW2b + BW3b + BW4b);
def BW1c= if Con1C == 1 and Con2C == 1 then 1 else 0;
def BW2c= if Con1C == 1 and Con2C == 0 then 2 else 0;
def BW3c= if Con1C == 0 and Con2C == 0 then 3 else 0;
def BW4c= if Con1C == 0 and Con2C == 1 then 4 else 0;
def SBc = (BW1c + BW2c + BW3c + BW4c);

Plot Dot9 = 9;
Dot9.SetpaintingStrategy(PaintingStrategy.Triangles);
Dot9.SetLineWeight(DotSize);
Dot9.AssignValueColor( if GZone1 == 1 then GlobalColor("GreenZone") else if RZone1 == 1 then GlobalColor("RedZone") else GlobalColor("Neutral"));
Plot Dot10 = 10;
Dot10.SetpaintingStrategy(PaintingStrategy.Triangles);
Dot10.SetLineWeight(DotSize);
Dot10.AssignValueColor( if GZone2 == 1 then GlobalColor("GreenZone") else if RZone2 == 1 then GlobalColor("RedZone") else GlobalColor("Neutral"));
Plot Dot11 = 11;
Dot11.SetpaintingStrategy(PaintingStrategy.Triangles);
Dot11.SetLineWeight(DotSize);
Dot11.AssignValueColor( if GZone3 == 1 then GlobalColor("GreenZone") else if RZone3 == 1 then GlobalColor("RedZone") else GlobalColor("Neutral"));
Plot Dot13 =13;
Dot13.SetpaintingStrategy(PaintingStrategy.Squares);
Dot13.SetLineWeight(3);
Dot13.assignValueColor(if SBa == 1 then GlobalColor("Greenbar") else if SBa == 2 then GlobalColor("Squatbar") else if SBa == 3 then GlobalColor("Fadebar") else if SBa == 4 then GlobalColor("Fakebar") else GlobalColor("Zero"));
Plot Dot14 =14;
Dot14.SetpaintingStrategy(PaintingStrategy.Squares);
Dot14.SetLineWeight(4);
Dot14.assignValueColor(if SBb == 1 then GlobalColor("Greenbar") else if SBb == 2 then GlobalColor("Squatbar") else if SBb == 3 then GlobalColor("Fadebar") else if SBb == 4 then GlobalColor("Fakebar") else GlobalColor("Zero"));
Plot Dot15 =15;
Dot15.SetpaintingStrategy(PaintingStrategy.Squares);
Dot15.SetLineWeight(5);
Dot15.assignValueColor(if SBc == 1 then GlobalColor("Greenbar") else if SBc == 2 then GlobalColor("Squatbar") else if SBc == 3 then GlobalColor("Fadebar") else if SBc == 4 then GlobalColor("Fakebar") else GlobalColor("Zero"));

AssignPriceColor( if APC == 1 and RecP == 1 then Color.Light_Green else if APC == 1 and WarnP == 1 then Color.Orange else if APC == 1 and AcumP == 1 then Color.Green else if APC == 1 and DispP == 1 then Color.Red else if APC ==1 and BullP ==1 then Color.Dark_Green else if  apc == 1 and BearP == 1 then Color.DarK_Red  Else
if APC == 2 and RecP == 1 then Color.Light_Green else if APC == 2 and WarnP == 2 then Color.Orange else if APC == 2 and AcumP == 2 then Color.Green else if APC == 2 and DispP == 2 then Color.Red else if APC ==2 and BullP ==2 then Color.Dark_Green else if  apc == 2 and BearP == 2 then Color.DarK_Red Else if  APC == 3 and RecP == 3 then Color.Light_Green else if APC == 3 and WarnP == 3 then Color.Orange else if APC == 3 and AcumP == 3 then Color.Green else if APC == 3 and DispP == 3 then Color.Red else if APC ==3 and BullP ==3 then Color.Dark_Green else if  apc == 3 and BearP == 3 then Color.DarK_Red  Else if APC ==5 and Trend == 1 then Color.Dark_Red else if APC == 5 and Trend == 2 then color.Green else if APC==5 and Trend == 3 then Color.Dark_Green else if APC ==5 and Trend ==4 then Color.Red else if APC ==6 and TrendB == 1 then Color.Dark_Red else if APC == 6 and TrendB == 2 then color.Green else if APC==6 and TrendB == 3 then Color.Dark_Green else if APC ==6 and TrendB ==4 then Color.Red else if APC ==7 and TrendC == 1 then Color.Dark_Red else if APC == 7 and TrendC == 2 then color.Green else if APC==7 and TrendC == 3 then Color.Dark_Green else if APC ==7 and TrendC ==4 then Color.Red else if apc == 9 and GZone1 == 1 then GlobalColor("GreenZone") else if apc == 9 and RZone1 == 1 then GlobalColor("RedZone") else if apc ==9 and GZone1 == 0 and RZone1 == 0 then GlobalColor("Neutral") else if apc == 10 and GZone2 == 1 then GlobalColor("GreenZone") else if apc == 10 and RZone2 == 1 then GlobalColor("RedZone") else if apc == 10 and Gzone2 ==0 and RZone2 == 0 then GlobalColor("Neutral") else if apc == 11 and GZone3 == 1 then GlobalColor("GreenZone") else if  apc == 11 and RZone3 == 1 then GlobalColor("RedZone") else if apc == 11 and Gzone3 ==0 and RZone3 ==0 then GlobalColor("Neutral") else if apc == 13 and SBa == 1 then GlobalColor(“Greenbar”) else if APC == 13 and SBa == 2 then GlobalColor(“Squatbar”) else if apc == 13 and SBa == 3 then GlobalColor(“Fadebar”) else if apc == 13 and SBa == 4 then GlobalColor(“Fakebar”) else if apc == 14 and SBb == 1 then GlobalColor(“Greenbar”) else if APC == 14 and SBb == 2 then GlobalColor(“Squatbar”) else if apc == 14 and SBb == 3 then GlobalColor(“Fadebar”) else if apc == 14 and SBb == 4 then GlobalColor(“Fakebar”)else if apc == 15 and SBc == 1 then GlobalColor(“Greenbar”) else if APC == 15 and SBc == 2 then GlobalColor(“Squatbar”) else if apc == 15 and SBc == 3 then GlobalColor(“Fadebar”) else if apc ==15 and SBc == 4 then GlobalColor(“Fakebar”) else Color.current);
 
Last edited:
Henry I am really enjoying this code. You did a great job! I can do a little coding but I was wondering if you could help with something that is out of my knowledge.

I wanted to make a watchlist indicator(never done this actually only lower studies) using this code and for it just to show the daily color close of the bar. So if its a squat bar itll show blue, fade itll show red etc.

Is something like that possible?

cheers
 
Can anyone help?
Is there a way to break this up into individual components (i.e one indicator for squat bar, one for tea 2.0, zones, etc...)?
I’m trying to go in there and break it up myself, but am getting error messages as I try to do that ( I’m new at this and am still learning).
Thanks anyone!!
 
Can anyone help?
Is there a way to break this up into individual components (i.e one indicator for squat bar, one for tea 2.0, zones, etc...)?
I’m trying to go in there and break it up myself, but am getting error messages as I try to do that ( I’m new at this and am still learning).
Thanks anyone!!
Hello DocBrown, I combined then into 1 indicator to save space on the chart and to eliminate the title bars for 3 indicators
 
I have not used tick charts nor the direction on squat or fake bars, I just used the description from the book
 
Last edited by a moderator:
Thanks Henry the code works great. I was wondering if there is an easy way to change the color of the volume bars instead of the price bars.
 
Thanks Henry the code works great. I was wondering if there is an easy way to change the color of the volume bars instead of the price bars.

Check out the Thinkorswim standard Study named SpectrumBars to see if that will help with volume...

 
Thanks rad14733. Using a combination of the code for the spectrum bars and the code provided by Henry1224 I was able to get the volume bars colored, but I haven't been able to get the price bars back to red and green. HMMM...

I'll add the code for price bars and volume bars colored to MFI
 
declare lower;
Input paint = yes;
DefineGlobalColor("Greenbar", Color.Green);
DefineGlobalColor("Squatbar", Color.Blue);
DefineGlobalColor("Fadebar", Color.Red);
DefineGlobalColor("Fakebar", Color.Orange);
DefineGlobalColor("Zero", Color.Gray);
def mfi = if volume > 0 then (high - low) / volume * 100 else 0;
def Con1 = if volume[1] > volume[2] then 1 else 0;
def Con2 = if mfi[1] > mfi[2] then 1 else 0;
def BW1= if Con1 == 1 and Con2 == 1 then 1 else 0;
def BW2= if Con1 == 1 and Con2 == 0 then 2 else 0;
def BW3= if Con1 == 0 and Con2 == 0 then 3 else 0;
def BW4= if Con1 == 0 and Con2 == 1 then 4 else 0;
def sb = (BW1 + BW2 + BW3 + BW4);
Plot vol = volume;
vol.SetPaintingStrategy(PaintingStrategy.histogram);
vol.setLineWeight(3);
vol.assignValueColor(if sb == 1 then GlobalColor("Greenbar") else if SB == 2 then GlobalColor("Squatbar") else if SB == 3 then GlobalColor("Fadebar") else if SB== 4 then GlobalColor("Fakebar") else GlobalColor("Zero"));
assignPriceColor(if Paint == yes and SB == 1 then GlobalColor("Greenbar") else if Paint == yes and SB == 2 then GlobalColor("Squatbar") else if paint == yes and SB == 3 then GlobalColor("Fadebar") else if paint == yes and SB == 4 then GlobalColor("Fakebar") else Color.Current);
 
I'm not great at coding. Does anybody see why the price bars are also being colored to match MFI, and can I change this to just color code the volume bars.
 
@WoodyWoody Your AssignPriceValue() call is the culprit... That call is used to color chart bars/candles and serves no other purpose in lower indicators...
 
declare lower;
Input paint = yes;
DefineGlobalColor("Greenbar", Color.Green);
DefineGlobalColor("Squatbar", Color.Blue);
DefineGlobalColor("Fadebar", Color.Red);
DefineGlobalColor("Fakebar", Color.Orange);
DefineGlobalColor("Zero", Color.Gray);
def mfi = if volume > 0 then (high - low) / volume * 100 else 0;
def Con1 = if volume[1] > volume[2] then 1 else 0;
def Con2 = if mfi[1] > mfi[2] then 1 else 0;
def BW1= if Con1 == 1 and Con2 == 1 then 1 else 0;
def BW2= if Con1 == 1 and Con2 == 0 then 2 else 0;
def BW3= if Con1 == 0 and Con2 == 0 then 3 else 0;
def BW4= if Con1 == 0 and Con2 == 1 then 4 else 0;
def sb = (BW1 + BW2 + BW3 + BW4);
Plot vol = volume;
vol.SetPaintingStrategy(PaintingStrategy.histogram);
vol.setLineWeight(3);
vol.assignValueColor(if sb == 1 then GlobalColor("Greenbar") else if SB == 2 then GlobalColor("Squatbar") else if SB == 3 then GlobalColor("Fadebar") else if SB== 4 then GlobalColor("Fakebar") else GlobalColor("Zero"));
assignPriceColor(if Paint == yes and SB == 1 then GlobalColor("Greenbar") else if Paint == yes and SB == 2 then GlobalColor("Squatbar") else if paint == yes and SB == 3 then GlobalColor("Fadebar") else if paint == yes and SB == 4 then GlobalColor("Fakebar") else Color.Current);
Code:
declare lower;
Input paint = yes;
DefineGlobalColor("Greenbar", Color.Green);
DefineGlobalColor("Squatbar", Color.Blue);
DefineGlobalColor("Fadebar", Color.Red);
DefineGlobalColor("Fakebar", Color.Orange);
def mfi = if volume > 0 then (high - low) / volume * 100 else 0;
def Con1 = if volume[1] > volume[2] then 1 else 0;
def Con2 = if mfi[1] > mfi[2] then 1 else 0;
def BW1= if Con1 == 1 and Con2 == 1 then 1 else 0;
def BW2= if Con1 == 1 and Con2 == 0 then 2 else 0;
def BW3= if Con1 == 0 and Con2 == 0 then 3 else 0;
def BW4= if Con1 == 0 and Con2 == 1 then 4 else 0;
def sb = (BW1 + BW2 + BW3 + BW4);
Plot vol = volume;
vol.SetPaintingStrategy(PaintingStrategy.histogram);
vol.setLineWeight(3);
vol.assignValueColor(if sb == 1 then GlobalColor("Greenbar") else if SB == 2 then GlobalColor("Squatbar") else if SB == 3 then GlobalColor("Fadebar") else GlobalColor("Fakebar"));
assignPriceColor(if Paint == yes and SB == 1 then GlobalColor("Greenbar") else if Paint == yes and SB == 2 then GlobalColor("Squatbar") else if paint == yes and SB == 3 then GlobalColor("Fadebar") else if paint == yes and SB == 4 then GlobalColor("Fakebar") else Color.Current);


Try this
 
Did anyone figure out how to trade with this indicator? Or any other indicator that goes well in hand with it?
 
Here is a version that combines the following indicators "Trend Advisor Diamond Phase", "Tea v2.0" , "Bill Williams Zone Bars" , & "Bill Williams SquatBars"
The documentation is included in the formula
All Indicators have Assign Price Color & 3_MTF's

Henry thank you for sharing! Can't load up this indicator, are there any changes I am missing that need to be done for it to start showing up? I have an empty space in place where indicator should be, thanks in advance for help!

Indicator that you've shared in this topic works great btw.
TEA combined with Trend Advisor Diamond Phase

Did anyone figure out how to trade with this indicator? Or any other indicator that goes well in hand with it?
You are going long in accumulation phase and short in distribution. But you need confluence with other indicators to do this.
 
Henry thank you for sharing! Can't load up this indicator, are there any changes I am missing that need to be done for it to start showing up? I have an empty space in place where indicator should be, thanks in advance for help!

Indicator that you've shared in this topic works great btw.
TEA combined with Trend Advisor Diamond Phase


You are going long in accumulation phase and short in distribution. But you need confluence with other indicators to do this.
You have to set your Time frames correctly for it to plot! What is the time frame that you are viewing?
Start with the time frame for the chart , then add the next higher time frame and so forth
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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