All indicators

Trend Following based on Trend Confidence

Dec 3, 2022

Static chart image
SignalsMoney Management

The Trend Following based on Trend Confidence indicator is a quantitative tool designed to identify and trade linear price trends by measuring the statistical confidence of the current market direction. It utilizes linear regression analysis to determine when a trend is sufficiently stable to warrant an entry, aiming to filter out market noise and sudden, non-linear price spikes.

Usage

The indicator can be used as a standalone strategy or a trend filter. Users monitor the "Trend Confidence" value relative to user-defined entry and exit thresholds.

  • Long Positions: A long entry is triggered when the Trend Confidence crosses above the Long Entry Threshold (typically a positive value). The position is held until the value crosses below the Long Exit Threshold.
  • Short Positions: A short entry is triggered when the Trend Confidence crosses below the Short Entry Threshold (typically a negative value). The position is closed when the value crosses back above the Short Exit Threshold.

The tool is optimized for markets like BTC-USD and ETH-USD on a 4-hour timeframe, though it can be adapted for other assets by adjusting the threshold parameters.

Details

The core logic relies on Ordinary Least Squares (OLS) Linear Regression. The script calculates two primary components over a lookback period defined by the Length parameter:

  1. Slope (b): The steepness of the linear fit, representing the rate of price change.
  2. Standard Deviation (sd): The deviation of actual closing prices from the linear fit line.

The Trend Confidence is calculated as the ratio of the Slope to the Standard Deviation ($b/sd$). A high ratio indicates a steep trend with very little deviation (high linearity), while a low ratio indicates either a flat trend or a very volatile/erratic price movement.

Settings

  • Source: The price data used for calculation (default is Close).
  • Start/End Trading Interval: Defines the backtesting range for the strategy.
  • Length: The lookback window used to calculate the linear regression and deviation.
  • Longs/Shorts: Toggle switches to enable or disable long or short signals respectively.
  • Long Entry Threshold: The confidence level required to open a long position.
  • Long Exit Threshold: The confidence level at which a long position is closed.
  • Short Entry Threshold: The confidence level required to open a short position.
  • Short Exit Threshold: The confidence level at which a short position is closed.
  • Stop Loss (percentage): A hard stop loss percentage to manage risk per trade.

FAQ

How do I use the Trend Confidence thresholds?

Thresholds should be set based on the historical volatility of the asset. Higher thresholds require more "perfect" linear moves for an entry, while lower thresholds are more sensitive but may result in more false signals.

What is the ideal timeframe for this indicator?

While originally designed for the 4-hour timeframe on cryptocurrency pairs, the mathematical logic of trend confidence is applicable to any timeframe, provided the Length and Threshold settings are adjusted to suit the specific market's volatility.

How can I access Trend Following based on Trend Confidence?

You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.