• The price of VIP membership is increasing to $199 beginning June 1. Click here to lock in the current rate of $149.

Bill Williams Squat Bars for ThinkorSwim

CLICKANDGRAB808

New member
VIP
Does anyone have an indicator for thinkorswim that duplicates bill Williams squat bars?

The squat bar is used to indicate a potential top/bottom or measuring squat (similar to measuring gap - expect movement length to continue for approx same range) - stands out more on the bar chart

Bill Williams / Profitunity indicators also include a "squat bar" which is colored blue. I presume this is based on the MFI so if the MFI bar is blue then the price bar would be blue
 

henry1224

Active member
VIP
Code:
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 sqBars = SB;
sqbars.SetPaintingStrategy(PaintingStrategy.histogram);
sqBars.setLineWeight(3);
sqBars.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);
 

henry1224

Active member
VIP
Here is a new version which I added Zone bars along with Multi time frames and the ability to paint bars.

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);
 

henry1224

Active member
VIP
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
 

Similar threads

Top