Logo
OFFLINEPIXEL
/ pinescript-strategies / pine-script-force-index

$ Pinescript Force Index

Master this unique indicator in TradingView's Pinescript that combines price action and volume to reveal the true driving force behind market movements.

500+ Clients Helped
100% Satisfaction
Live Trading Ready
⚠️
Trading financial markets carries risk. All content (PineScript code, indicators, strategies) on this website is for educational purposes only. Past performance is not indicative of future results. By using any code or information from this site, you agree that you are solely responsible for your trading decisions. The author disclaims all liability for any losses incurred. To gain from experts experiences, You can always try our Invite Only Scripts
01

What is the Force Index?

The Force Index (FI), developed by Alexander Elder, is a unique oscillator that measures the strength of buying and selling pressure by combining price movement and volume. Unlike pure momentum indicators that only consider price, Force Index gives greater significance to large price changes that occur on high volume, indicating a strong force pushing the market. It can be positive (bullish force) or negative (bearish force) and oscillates around a zero line.

In Pinescript, Force Index is a powerful tool for confirming trend strength, spotting potential reversals through divergence, and identifying when strong money is entering or leaving the market.

02

Components and Calculation

The core calculation of the Force Index for a single period is quite simple:

  1. Single Period Force Index:
    `Force Index = Volume * (Current Close - Previous Close)`
    A positive value indicates that buyers are in control (price went up on volume), while a negative value indicates sellers are in control (price went down on volume).
  2. Smoothed Force Index: To make the indicator more useful and reduce noise, the single-period Force Index is usually smoothed using an Exponential Moving Average (EMA) over a specified `length`.
    `Smoothed Force Index = EMA(Force Index, length)`
    Common lengths for smoothing are 1 (raw), 2 (short-term), or 13 (long-term).
03

Basic Force Index Implementation in Pinescript

pine-script@terminal
//@version=5
indicator("My Force Index Indicator", overlay=false) // overlay=false to plot in a separate pane

// Input for Force Index length (smoothing period for the raw FI)
length = input.int(13, title="FI Length (EMA Smoothing)", minval=1)

// Calculate Force Index using the built-in function
// ta.fi takes the source (usually close) and the length for EMA smoothing
fiValue = ta.fi(close, length)

// Plot the Force Index line
plot(fiValue, title="Force Index", color=color.blue, linewidth=2)

// Plot the Zero Line
hline(0, "Zero Line", color.gray, linestyle=hline.style_dotted)
$ ✓ Compiled successfully
04

Interpretation

Interpretation

A positive Force Index indicates buying pressure, a negative one indicates selling pressure. The magnitude reflects the strength of that pressure.

05

Practical Force Index Trading Strategies

06

1. Trend Confirmation

pine-script@terminal
//@version=5
strategy("Force Index Trend Confirmation Strategy", overlay=true)

// Input for Force Index length
length = input.int(13, title="FI Length (EMA Smoothing)", minval=1)

// Calculate Force Index
fiValue = ta.fi(close, length)

// Plot the Force Index line in a separate pane
plot(fiValue, title="Force Index", color.blue, display=display.pane_only)
hline(0, "Zero Line", color.gray, linestyle=hline.style_dotted, display=display.pane_only)

// Define conditions for entries based on consistent FI direction
// Long when FI is positive and rising
longCondition = fiValue > 0 and fiValue > fiValue[1]
// Short when FI is negative and falling
shortCondition = fiValue < 0 and fiValue < fiValue[1]

// Strategy entries/exits
if (longCondition)
    strategy.entry("Long", strategy.long)

if (shortCondition)
    strategy.entry("Short", strategy.short)
$ ✓ Compiled successfully
07

2. Zero Line Crossover (Momentum Shift)

pine-script@terminal
//@version=5
strategy("Force Index Zero Line Crossover Strategy", overlay=true)

// Input for Force Index length (often shorter for crossover signals)
length = input.int(2, title="FI Length (EMA Smoothing)", minval=1)

// Calculate Force Index
fiValue = ta.fi(close, length)

// Plot the Force Index line in a separate pane
plot(fiValue, title="Force Index", color.blue, display=display.pane_only)
hline(0, "Zero Line", color.gray, linestyle=hline.style_dotted, display=display.pane_only)

// Define conditions for entries
longSignal = ta.crossover(fiValue, 0)
shortSignal = ta.crossunder(fiValue, 0)

// Strategy entries/exits
if (longSignal)
    strategy.entry("Long", strategy.long)

if (shortSignal)
    strategy.entry("Short", strategy.short)
$ ✓ Compiled successfully
08

3. Force Index Divergence Strategy

pine-script@terminal
//@version=5
indicator("Force Index Divergence Scanner", overlay=true)

// Input for Force Index length
length = input.int(13, title="FI Length (EMA Smoothing)", minval=1)

// Calculate Force Index
fiValue = ta.fi(close, length)

// Plot Force Index in a separate pane
plot(fiValue, "Force Index", color.blue)
hline(0, "Zero Line", color.gray, linestyle=hline.style_dotted)

// Simple divergence detection (conceptual, robust detection requires advanced pivot logic)
// This is a simplified example focusing on price vs FI divergence.

// Bullish Divergence (Price lower low, FI higher low)
bullishDivergence = close[2] > close[1] and close[1] > close and fiValue[2] < fiValue[1] and fiValue[1] < fiValue

// Bearish Divergence (Price higher high, FI lower high)
bearishDivergence = close[2] < close[1] and close[1] < close and fiValue[2] > fiValue[1] and fiValue[1] > fiValue

plotshape(bullishDivergence, title="Bullish Divergence", location=location.belowbar, color=color.new(color.green, 0), style=shape.triangleup, size=size.small)
plotshape(bearishDivergence, title="Bearish Divergence", location=location.abovebar, color=color.new(color.red, 0), style=shape.triangledown, size=size.small)

alertcondition(bullishDivergence, "Bullish FI Divergence", "Potential bullish reversal based on Force Index divergence.")
alertcondition(bearishDivergence, "Bearish FI Divergence", "Potential bearish reversal based on Force Index divergence.")
$ ✓ Compiled successfully
09

Optimizing Force Index Performance

To get the most from the Force Index in Pinescript:

  • Parameter Tuning: The `length` parameter is crucial.
    • Short Lengths (e.g., 1 or 2 periods): Used for short-term signals and quick reactions to price/volume surges. Excellent for confirming individual bar strength.
    • Medium/Long Lengths (e.g., 13 periods): Used for identifying the dominant trend and more reliable divergence signals. This smoothed version helps filter out noise.
    Experiment to find optimal settings for your specific asset and timeframe.
  • Combine with Price Action: Force Index is powerful because it integrates volume. Look for FI signals that are confirmed by significant price action, such as breaks of support/resistance, candlestick patterns, or large volume spikes on the price chart.
  • Multi-Timeframe Analysis: Use a longer-term Force Index on a higher timeframe to confirm the overall trend, then look for entry/exit signals from a shorter-term Force Index on a lower timeframe.
  • Use with Trend-Following Indicators: Since Force Index helps confirm trend strength, it's often best used in conjunction with a trend-following indicator (like a moving average or ADX) to ensure you are trading in the direction of the larger trend.
10

The "Force" of the Move

The "Force" of the Move

The higher the Force Index, the stronger the bullish force. The lower (more negative) the Force Index, the stronger the bearish force. Volume is the key differentiator here.

11

Common Force Index Pitfalls

  • Requires Volume Data: Force Index relies heavily on accurate volume data. For assets or exchanges where volume data is unreliable or unavailable, Force Index will not be effective.
  • Lag (especially with longer lengths): Like all smoothed indicators, the Force Index will have some lag, especially when using longer lengths. Short lengths can be noisy.
  • False Signals in Ranging Markets: In non-trending or highly choppy markets, Force Index can oscillate around the zero line, generating frequent and often unreliable signals.
  • Divergence Can Be Early: While divergence is a strong signal, it can appear early, and the trend might continue for some time after the divergence appears, requiring patience and additional confirmation.
  • Not a Standalone Indicator: Force Index should always be used as part of a broader trading system, combined with other indicators and price action analysis for confirmation.
12

Conclusion

Conclusion

The Force Index is a unique and highly insightful technical indicator in Pinescript for TradingView. Its integration of both price change and volume provides a powerful measure of the underlying buying and selling pressure in the market. Whether used for confirming trend strength, identifying momentum shifts through zero-line crossovers, or spotting potential reversals via divergence, the Force Index offers valuable insights. By understanding its calculation, thoughtfully tuning its parameters, and integrating it strategically with other technical analysis tools, you can leverage the Force Index to gain a deeper, volume-confirmed perspective on market dynamics and enhance your trading decisions.

Enhance Your Trading

Get a high-performance Pinescript analysis tool for actionable market insights, designed for traders on the move.

This strategy runs in live mode on TradingView, helping you identify potential opportunities.

Get Pinescript Strategy