Repaints MTF Force Index Binary for ThinkorSwim

Repaints

henry1224

Expert
VIP
Lifetime
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

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:

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

MTF Force Index Binary WatchList Column
shared watchlist column link: http://tos.mx/UCh62nN Click here for --> Easiest way to load shared links
a1.png

Screenshot (85).png

Ruby:
################
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;

Def FI5 = ExpAverage(data = (CP - CP[1]) * VP,F5length);
def Bullish5 = FI5 >=0;
def Bearish5 = FI5 < 0;

Def FI8 = ExpAverage(data = (CP - CP[1]) * VP,F8length);
def Bullish8 = FI8 >=0;
def Bearish8 = FI8 < 0;

Def FI13 = ExpAverage(data = (CP - CP[1]) * VP,F13length);
def Bullish13 = FI13 >=0;
def Bearish13 = FI13 < 0;

Def FI21 = ExpAverage(data = (CP - CP[1]) * VP,F21length);
def Bullish21 = FI21 >=0;
def Bearish21 = FI21 < 0;

#Aggregation 2
Def A2FI2 = ExpAverage(data = (CP2 – CP2[1]) * VP2,F2length);
def A2Bullish2 = A2FI2 >=0;
def A2Bearish2 = A2FI2 < 0;

Def A2FI5 = ExpAverage(data = (CP2 – CP2[1]) * VP2,F5length);
def A2Bullish5 = A2FI5 >=0;
def A2Bearish5 = A2FI5 < 0;

Def A2FI8 = ExpAverage(data = (CP2 – CP2[1]) * VP2,F8length);
def A2Bullish8 = A2FI8 >=0;
def A2Bearish8 = A2FI8 < 0;

Def A2FI13 = ExpAverage(data = (CP2 – CP2[1]) * VP2,F13length);
def A2Bullish13 = A2FI13 >=0;
def A2Bearish13 = A2FI13 < 0;

Def A2FI21 = ExpAverage(data = (CP2 – CP2[1]) * VP2,F21length);
def A2Bullish21 = A2FI21 >=0;
def A2Bearish21 = A2FI21 < 0;

#Aggregation 3
Def A3FI2 = ExpAverage(data = (CP3 – CP3[1]) * VP3,F2length);
def A3Bullish2 = A3FI2 >=0;
def A3Bearish2 = A3FI2 < 0;

Def A3FI5 = ExpAverage(data = (CP3 – CP3[1]) * VP3,F5length);
def A3Bullish5 = A3FI5 >=0;
def A3Bearish5 = A3FI5 < 0;

Def A3FI8 = ExpAverage(data = (CP3 – CP3[1]) * VP3,F8length);
def A3Bullish8 = A3FI8 >=0;
def A3Bearish8 = A3FI8 < 0;

Def A3FI13 = ExpAverage(data = (CP3 – CP3[1]) * VP3,F13length);
def A3Bullish13 = A3FI13 >=0;
def A3Bearish13 = A3FI13 < 0;

Def A3FI21 = ExpAverage(data = (CP3 – CP3[1]) * VP3,F21length);
def A3Bullish21 = A3FI21 >=0;
def A3Bearish21 = A3FI21 < 0;

def stacked =
#Aggregation 1
Bearish2  < Bullish2  and
Bearish5  < Bullish5  and
Bearish8  < Bullish8  and
Bearish13 < Bullish13 and
Bearish21 < Bullish21 and
#Aggregation 2
A2Bearish2  < A2Bullish2  and
A2Bearish5  < A2Bullish5  and
A2Bearish8  < A2Bullish8  and
A2Bearish13 < A2Bullish13 and
A2Bearish21 < A2Bullish21 and
#Aggregation 3
A3Bearish2  < A3Bullish2  and
A3Bearish5  < A3Bullish5  and
A3Bearish8  < A3Bullish8  and
A3Bearish13 < A3Bullish13 and
A3Bearish21 < A3Bullish21  ;

AddLabel(yes, " ") ;
AssignBackgroundColor(
if stacked then color.green else
if !stacked then color.red else
 color.gray) ;
@nktkobby
 
The Trend Reversal Indicator repaints. A lot on the lower aggregations and still some on the higher aggregations.
 
@henry1224 Thanks for providing this great indicator. I use the Force Index indicator, and this allows me the freedom to not have to have multiple timeframe charts open at the same time. It repaints, but is still useful for identifying trend.
 
Last edited:
@henry1224 Thanks for providing this great indicator. I use the Force Index indicator, and this allows me the freedom to not have to have multiple timeframe charts open at the same time. It repaints, but is still useful for identifying trend.
Just for your peace of mind , All indicators that use a MTF function will repaint except for the current Time frame.

That means that the lower third of the indicator will not repaint if set to the current time frame!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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