Each time frame also has a consensus line.

the shortest length is on the bottom and rises up to the highest length, the same hold true for the time frames current time frame on the bottom and then the next higher time frame

So here is the code

Code:

```
##############
Declare Lower;
# GLOBAL DEFINITIONS
DefineGlobalColor("TrendUp", Color.Cyan);
DefineGlobalColor("TrendDown", Color.Magenta);
input agg = AggregationPeriod.FIVE_MIN;
input agg2 = AggregationPeriod.THIRTY_MIN;
input agg3 = AggregationPeriod.HOUR;
input DotSize = 4;
input n = 20;
def n1 = n + 1;
def O = Open(Period = AGG);
def C = Close(Period =AGG);
def O2 = Open(Period = AGG2);
def C2 = Close(Period =AGG2);
def O3 = Open(Period = AGG3);
def C3 = Close(Period =AGG3);
Def BIAS3 = ((O+C)/2 - Average ((O+C)/2,3))/ Average((O+C)/2,3)*100;
Def BIAS6 = ((O+C)/2 - Average ((O+C)/2,6))/ Average ((O+C)/2,6)*100;
Def BIAS9 = ((O+C)/2 - Average ((O+C)/2,9))/ Average ((O+C)/2,9)*100;
Def BIAS12 = ((O+C)/2 - Average ((O+C)/2,12))/ Average ((O+C)/2,12)*100;
Def BIAS15 = ((O+C)/2 - Average ((O+C)/2,15))/ Average ((O+C)/2,15)*100;
Def A3 = If(Bias3>=0,1,0);
Def A6 = If(Bias6>=0,1,0);
Def A9 = If(Bias9>=0,1,0);
Def A12= If(Bias12>=0,1,0);
Def A15 = If(Bias15>=0,1,0);
Def BBIAS3 = ((O2+C2)/2 -Average((O2+C2)/2,3))/ Average((O2+C2)/2,3)*100;
Def BBIAS6 = ((O2+C2)/2 - Average((O2+C2)/2,6))/ Average((O2+C2)/2,6)*100;
Def BBIAS9 = ((O2+C2)/2 - Average((O2+C2)/2,9))/ Average((O2+C2)/2,9)*100;
Def BBIAS12 = ((O2+C2)/2 - Average((O2+C2)/2,12))/ Average((O2+C2)/2,12)*100;
Def BBIAS15 = ((O2+C2)/2 - Average((O2+C2)/2,15))/ Average((O2+C2)/2,15)*100;
Def B3 = If(BBias3>=0,1,0);
Def B6 = If(BBias6>=0,1,0);
Def B9 = If(BBias9>=0,1,0);
Def B12= If(BBias12>=0,1,0);
Def B15 = If(BBias15>=0,1,0);
Def CBIAS3 = ((O3+C3)/2 -Average((O3+C3)/2,3))/ Average((O3+C3)/2,3)*100;
Def CBIAS6 = ((O3+C3)/2 - Average((O3+C3)/2,6))/ Average((O3+C3)/2,6)*100;
Def CBIAS9 = ((O3+C3)/2 - Average((O3+C3)/2,9))/ Average((O3+C3)/2,9)*100;
Def CBIAS12 = ((O3+C3)/2 - Average((O3+C3)/2,12))/ Average((O3+C3)/2,12)*100;
Def CBIAS15 = ((O3+C3)/2 - Average((O3+C3)/2,15))/ Average((O3+C3)/2,15)*100;
Def CC3 = If(CBias3>=0,1,0);
Def CC6 = If(CBias6>=0,1,0);
Def CC9 = If(CBias9>=0,1,0);
Def CC12= If(CBias12>=0,1,0);
Def CC15 = If(CBias15>=0,1,0);
plot A3_Dot = if IsNaN(c) then Double.NaN else 1;
A3_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A3_Dot.SetLineWeight(DotSize);
A3_Dot.AssignValueColor(if A3 < 1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c[n1]) and IsNaN(c[n]), 1, (agg/1000/60) + " min", Color.Yellow, yes);
plot A6_Dot = if IsNaN(c) then Double.NaN else 2;
A6_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A6_Dot.SetLineWeight(DotSize);
A6_Dot.AssignValueColor(if A6 < 1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c[n1]) and IsNaN(c[n]), 2, (agg/1000/60) + " min", Color.Yellow, yes);
plot A9_Dot = if IsNaN(c) then Double.NaN else 3;
A9_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A9_Dot.SetLineWeight(DotSize);
A9_Dot.AssignValueColor(if A9 < 1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c[n1]) and IsNaN(c[n]), 3, (agg/1000/60) + " min", Color.Yellow, yes);
plot A12_Dot = if IsNaN(c) then Double.NaN else 4;
A12_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A12_Dot.SetLineWeight(DotSize);
A12_Dot.AssignValueColor(if A12 < 1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c[n1]) and IsNaN(c[n]), 4, (agg/1000/60) + " min", Color.Yellow, yes);
plot A15_Dot = if IsNaN(c) then Double.NaN else 5;
A15_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A15_Dot.SetLineWeight(DotSize);
A15_Dot.AssignValueColor(if A15 < 1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c[n1]) and IsNaN(c[n]), 5, (agg/1000/60) + " min", Color.Yellow, yes);
plot MTF_ADot = 6;
MTF_ADot.SetPaintingStrategy(PaintingStrategy.SQUARES);
MTF_ADot.SetLineWeight(lineWeight = 3);
MTF_ADot.DefineColor("Buy", Color.Green);
MTF_ADot.DefineColor("Sell", Color.red);
MTF_ADot.AssignValueColor ( if (A3 + A6 + A9 + A12 + A15) >= 3 then MTF_ADot.Color("Buy") else MTF_ADot.Color("Sell"));
plot B3_Dot = if IsNaN(c2) then Double.NaN else 8;
B3_Dot.SetPaintingStrategy(PaintingStrategy.Points);
B3_Dot.SetLineWeight(DotSize);
B3_Dot.AssignValueColor(if B3 < 1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c2[n1]) and IsNaN(c2[n]), 8, (agg2/1000/60) + " min", Color.Yellow, yes);
plot B6_Dot = if IsNaN(c2) then Double.NaN else 9;
B6_Dot.SetPaintingStrategy(PaintingStrategy.Points);
B6_Dot.SetLineWeight(DotSize);
B6_Dot.AssignValueColor(if B6 < 1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c2[n1]) and IsNaN(c2[n]), 9, (agg2/1000/60) + " min", Color.Yellow, yes);
plot B9_Dot = if IsNaN(c2) then Double.NaN else 10;
B9_Dot.SetPaintingStrategy(PaintingStrategy.Points);
B9_Dot.SetLineWeight(DotSize);
B9_Dot.AssignValueColor(if B9 < 1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c2[n1]) and IsNaN(c2[n]), 10, (agg2/1000/60) + " min", Color.Yellow, yes);
plot B12_Dot = if IsNaN(c2) then Double.NaN else 11;
B12_Dot.SetPaintingStrategy(PaintingStrategy.Points);
B12_Dot.SetLineWeight(DotSize);
B12_Dot.AssignValueColor(if B12 < 1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c2[n1]) and IsNaN(c2[n]), 11, (agg2/1000/60) + " min", Color.Yellow, yes);
plot B15_Dot = if IsNaN(c2) then Double.NaN else 12;
B15_Dot.SetPaintingStrategy(PaintingStrategy.Points);
B15_Dot.SetLineWeight(DotSize);
B15_Dot.AssignValueColor(if B15 < 1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c[n1]) and IsNaN(c2[n]), 12, (agg2/1000/60) + " min", Color.Yellow, yes);
plot MTF_BDot = 13;
MTF_BDot.SetPaintingStrategy(PaintingStrategy.SQUARES);
MTF_BDot.SetLineWeight(lineWeight = 3);
MTF_BDot.DefineColor("Buy", Color.Green);
MTF_BDot.DefineColor("Sell", Color.red);
MTF_BDot.AssignValueColor ( if (B3 + B6 + B9 + B12 + B15) >= 3 then MTF_BDot.Color("Buy") else MTF_BDot.Color("Sell"));
plot CC3_Dot = if IsNaN(c3) then Double.NaN else 15;
CC3_Dot.SetPaintingStrategy(PaintingStrategy.Triangles);
CC3_Dot.SetLineWeight(DotSize);
CC3_Dot.AssignValueColor(if CC3 < 1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c3[n1]) and IsNaN(c3[n]), 15, (agg3/1000/60) + " min", Color.Yellow, yes);
plot CC6_Dot = if IsNaN(c3) then Double.NaN else 16;
CC6_Dot.SetPaintingStrategy(PaintingStrategy.Triangles);
CC6_Dot.SetLineWeight(DotSize);
CC6_Dot.AssignValueColor(if CC6 < 1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c3[n1]) and IsNaN(c3[n]), 16, (agg3/1000/60) + " min", Color.Yellow, yes);
plot CC9_Dot = if IsNaN(c3) then Double.NaN else 17;
CC9_Dot.SetPaintingStrategy(PaintingStrategy.Triangles);
CC9_Dot.SetLineWeight(DotSize);
CC9_Dot.AssignValueColor(if CC9 < 1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c3[n1]) and IsNaN(c3[n]), 17, (agg3/1000/60) + " min", Color.Yellow, yes);
plot CC12_Dot = if IsNaN(c3) then Double.NaN else 18;
CC12_Dot.SetPaintingStrategy(PaintingStrategy.Triangles);
CC12_Dot.SetLineWeight(DotSize);
CC12_Dot.AssignValueColor(if CC12 < 1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c3[n1]) and IsNaN(c3[n]), 18, (agg3/1000/60) + " min", Color.Yellow, yes);
plot CC15_Dot = if IsNaN(c3) then Double.NaN else 19;
CC15_Dot.SetPaintingStrategy(PaintingStrategy.Triangles);
CC15_Dot.SetLineWeight(DotSize);
CC15_Dot.AssignValueColor(if CC15 < 1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(c3[n1]) and IsNaN(c3[n]), 19, (agg3/1000/60) + " min", Color.Yellow, yes);
plot MTF_CDot = 20;
MTF_CDot.SetPaintingStrategy(PaintingStrategy.SQUARES);
MTF_CDot.SetLineWeight(lineWeight = 3);
MTF_CDot.DefineColor("Buy", Color.Green);
MTF_CDot.DefineColor("Sell", Color.red);
MTF_CDot.AssignValueColor ( if (CC3 + CC6 + CC9 + CC12 + CC15) >= 3 then MTF_CDot.Color("Buy") else MTF_CDot.Color("Sell"));
```