Here is a Binary indicator that shows 5 different lengths of the Force Index" bullish or Bearish " over 3 different Time frames
Here is the code
Here you go
Here is the code
Code:
###############
Declare Lower;
# GLOBAL DEFINITIONS
DefineGlobalColor("TrendUp", CreateColor(0, 254, 30));
DefineGlobalColor("TrendDown", CreateColor(255, 3, 2));
input agg = AggregationPeriod.FIVE_MIN;
input agg2 = AggregationPeriod.THIRTY_MIN;
input agg3 = AggregationPeriod.HOUR;
input DotSize = 5;
input n = 17;
def n1 = n + 1;
input F2length = 2;
input F5length = 5;
input F8length = 8;
input F13length = 13;
input F21length = 21;
def CP = close(Period = AGG);
def VP = Volume(Period = AGG);
def CP2 = close(Period = AGG2);
def VP2 = Volume(Period = AGG2);
def CP3 = close(Period = AGG3);
def VP3 = Volume(Period = AGG3);
#Aggregation 1
Def FI2 = ExpAverage(data = (CP - CP[1]) * VP,F2length);
def Bullish2 = FI2 >=0;
def Bearish2 = FI2 < 0;
plot FI2_Dot = if IsNaN(close) then Double.NaN else 1;
FI2_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
FI2_Dot.SetLineWeight(DotSize);
FI2_Dot.AssignValueColor(if Bearish2 > Bullish2 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(close [n1]) and IsNaN(Close [n]), 1, (agg/1000/60) + " min", Color.Yellow, yes);
Def FI5 = ExpAverage(data = (CP - CP[1]) * VP,F5length);
def Bullish5 = FI5 >=0;
def Bearish5 = FI5 < 0;
plot FI5_Dot = if IsNaN(close) then Double.NaN else 2;
FI5_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
FI5_Dot.SetLineWeight(DotSize);
FI5_Dot.AssignValueColor(if Bearish5 > Bullish5 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(close [n1]) and IsNaN(Close [n]), 2, (agg/1000/60) + " min", Color.Yellow, yes);
Def FI8 = ExpAverage(data = (CP - CP[1]) * VP,F8length);
def Bullish8 = FI8 >=0;
def Bearish8 = FI8 < 0;
plot FI8_Dot = if IsNaN(close) then Double.NaN else 3;
FI8_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
FI8_Dot.SetLineWeight(DotSize);
FI8_Dot.AssignValueColor(if Bearish8 > Bullish8 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(close [n1]) and IsNaN(Close [n]), 3, (agg/1000/60) + " min", Color.Yellow, yes);
Def FI13 = ExpAverage(data = (CP - CP[1]) * VP,F13length);
def Bullish13 = FI13 >=0;
def Bearish13 = FI13 < 0;
plot FI13_Dot = if IsNaN(close) then Double.NaN else 4;
FI13_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
FI13_Dot.SetLineWeight(DotSize);
FI13_Dot.AssignValueColor(if Bearish13 > Bullish13 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(close [n1]) and IsNaN(Close [n]), 4, (agg/1000/60) + " min", Color.Yellow, yes);
Def FI21 = ExpAverage(data = (CP - CP[1]) * VP,F21length);
def Bullish21 = FI21 >=0;
def Bearish21 = FI21 < 0;
plot FI21_Dot = if IsNaN(close) then Double.NaN else 5;
FI21_Dot.SetPaintingStrategy(PaintingStrategy.Triangles);
FI21_Dot.SetLineWeight(DotSize);
FI21_Dot.AssignValueColor(if Bearish21 > Bullish21 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(close [n1]) and IsNaN(Close [n]), 5, (agg/1000/60) + " min", Color.Yellow, yes);
#Aggregation 2
Def A2FI2 = ExpAverage(data = (CP2 – CP2[1]) * VP2,F2length);
def A2Bullish2 = A2FI2 >=0;
def A2Bearish2 = A2FI2 < 0;
plot A2FI2_Dot = if IsNaN(close) then Double.NaN else 7;
A2FI2_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A2FI2_Dot.SetLineWeight(DotSize);
A2FI2_Dot.AssignValueColor(if A2Bearish2 > A2Bullish2 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(close [n1]) and IsNaN(Close [n]), 7, (agg2/1000/60) + " min", Color.Yellow, yes);
Def A2FI5 = ExpAverage(data = (CP2 – CP2[1]) * VP2,F5length);
def A2Bullish5 = A2FI5 >=0;
def A2Bearish5 = A2FI5 < 0;
plot A2FI5_Dot = if IsNaN(close) then Double.NaN else 8;
A2FI5_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A2FI5_Dot.SetLineWeight(DotSize);
A2FI5_Dot.AssignValueColor(if A2Bearish5 > A2Bullish5 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(close [n1]) and IsNaN(Close [n]),8, (agg2/1000/60) + " min", Color.Yellow, yes);
Def A2FI8 = ExpAverage(data = (CP2 – CP2[1]) * VP2,F8length);
def A2Bullish8 = A2FI8 >=0;
def A2Bearish8 = A2FI8 < 0;
plot A2FI8_Dot = if IsNaN(close) then Double.NaN else 9;
A2FI8_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A2FI8_Dot.SetLineWeight(DotSize);
A2FI8_Dot.AssignValueColor(if A2Bearish8 > A2Bullish8 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(close [n1]) and IsNaN(Close [n]),9, (agg2/1000/60) + " min", Color.Yellow, yes);
Def A2FI13 = ExpAverage(data = (CP2 – CP2[1]) * VP2,F13length);
def A2Bullish13 = A2FI13 >=0;
def A2Bearish13 = A2FI13 < 0;
plot A2FI13_Dot = if IsNaN(close) then Double.NaN else 10;
A2FI13_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A2FI13_Dot.SetLineWeight(DotSize);
A2FI13_Dot.AssignValueColor(if A2Bearish13 > A2Bullish13 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(close [n1]) and IsNaN(Close [n]), 10, (agg2/1000/60) + " min", Color.Yellow, yes);
Def A2FI21 = ExpAverage(data = (CP2 – CP2[1]) * VP2,F21length);
def A2Bullish21 = A2FI21 >=0;
def A2Bearish21 = A2FI21 < 0;
plot A2FI21_Dot = if IsNaN(close) then Double.NaN else 11;
A2FI21_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A2FI21_Dot.SetLineWeight(DotSize);
A2FI21_Dot.AssignValueColor(if A2Bearish21 > A2Bullish21 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(close [n1]) and IsNaN(Close [n]), 11, (agg2/1000/60) + " min", Color.Yellow, yes);
#Aggregation 3
Def A3FI2 = ExpAverage(data = (CP3 – CP3[1]) * VP3,F2length);
def A3Bullish2 = A3FI2 >=0;
def A3Bearish2 = A3FI2 < 0;
plot A3FI2_Dot = if IsNaN(close) then Double.NaN else 13;
A3FI2_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A3FI2_Dot.SetLineWeight(DotSize);
A3FI2_Dot.AssignValueColor(if A3Bearish2 > A3Bullish2 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(close [n1]) and IsNaN(Close [n]), 13, (agg3/1000/60) + " min", Color.Yellow, yes);
Def A3FI5 = ExpAverage(data = (CP3 – CP3[1]) * VP3,F5length);
def A3Bullish5 = A3FI5 >=0;
def A3Bearish5 = A3FI5 < 0;
plot A3FI5_Dot = if IsNaN(close) then Double.NaN else 14;
A3FI5_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A3FI5_Dot.SetLineWeight(DotSize);
A3FI5_Dot.AssignValueColor(if A3Bearish5 > A3Bullish5 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(close [n1]) and IsNaN(Close [n]), 14, (agg3/1000/60) + " min", Color.Yellow, yes);
Def A3FI8 = ExpAverage(data = (CP3 – CP3[1]) * VP3,F8length);
def A3Bullish8 = A3FI8 >=0;
def A3Bearish8 = A3FI8 < 0;
plot A3FI8_Dot = if IsNaN(close) then Double.NaN else 15;
A3FI8_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A3FI8_Dot.SetLineWeight(DotSize);
A3FI8_Dot.AssignValueColor(if A3Bearish8 > A3Bullish8 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(close [n1]) and IsNaN(Close [n]), 15, (agg3/1000/60) + " min", Color.Yellow, yes);
Def A3FI13 = ExpAverage(data = (CP3 – CP3[1]) * VP3,F13length);
def A3Bullish13 = A3FI13 >=0;
def A3Bearish13 = A3FI13 < 0;
plot A3FI13_Dot = if IsNaN(close) then Double.NaN else 16;
A3FI13_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A3FI13_Dot.SetLineWeight(DotSize);
A3FI13_Dot.AssignValueColor(if A3Bearish13 > A3Bullish13 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(close [n1]) and IsNaN(Close [n]), 16, (agg3/1000/60) + " min", Color.Yellow, yes);
Def A3FI21 = ExpAverage(data = (CP3 – CP3[1]) * VP3,F21length);
def A3Bullish21 = A3FI21 >=0;
def A3Bearish21 = A3FI21 < 0;
plot A3FI21_Dot = if IsNaN(close) then Double.NaN else 17;
A3FI21_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A3FI21_Dot.SetLineWeight(DotSize);
A3FI21_Dot.AssignValueColor(if A3Bearish21 > A3Bullish21 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
AddChartBubble(!IsNaN(close [n1]) and IsNaN(Close [n]), 17, (agg3/1000/60) + " min", Color.Yellow, yes);
Here you go
Last edited by a moderator: