All indicators

Hyperbolic Tangent Volatility Stop

Sep 22, 2024

Static chart image
SignalsMoving AveragesTrailing-StopVolatility

The Hyperbolic Tangent Volatility Stop indicator provides a sophisticated trend-following framework by merging the smoothing properties of a non-linear moving average with a dynamic, volatility-adjusted stop mechanism. It aims to filter market noise and identify significant trend reversals while adapting to changing market conditions.

Usage

The tool is primarily used to identify trend direction and potential exit or entry points. It operates in two main modes:

  • Overlay Mode: Displays the Hyperbolic Tangent Moving Average (HTMA) and the Volatility Stop directly on the price chart. When the stop is below the price, it indicates an uptrend (Green); when above, it indicates a downtrend (Red).
  • Backtest Mode: Transitions the indicator to a separate pane to display an equity curve. This allows users to compare the performance of the indicator's signals against a standard buy-and-hold strategy based on historical data.

Traders can use the HTMA as a baseline for trend strength and the Volatility Stop circles as dynamic trailing stop-loss levels.

Details

The script is constructed using two core mathematical components:

  1. Hyperbolic Tangent Moving Average (HTMA): This uses the tanh function to "squash" price deviations from a simple moving average. By applying this non-linear transformation, the average becomes less sensitive to extreme price spikes, resulting in a smoother trend line that focuses on persistent directional movement. Note that accuracy may decrease for assets priced significantly above 100,000 due to the nature of the hyperbolic tangent function.
  2. Volatility Stop: Built using the Average True Range (ATR), this mechanism follows the HTMA. In an uptrend, the stop is calculated by subtracting a multiple of the ATR from the highest price reached. As volatility increases, the stop widens to prevent premature exits; as volatility decreases, the stop tightens to protect gains.

Settings

General Settings

  • Display Mode: Switches between "Overlay" (chart view) and "Backtest Mode" (performance view).
  • Allow Intra-day Updating: Enables real-time signal updates within the current bar. Disabling this waits for the bar to close to confirm signals.
  • Plot Calculation Source: Toggles the visibility of the specific price source used for calculations.
  • Color Bars?: When enabled, colors the price bars based on the current trend direction.

HTMA Settings

  • HTMA Length: The lookback period for the Hyperbolic Tangent Moving Average.
  • Source: The price input used (e.g., Close, HL2, OCC3).
  • Hyperbolic Tangent Multiplier: Controls the intensity of the non-linear "squashing" effect.
  • Plot HTMA?: Toggles the visibility of the HTMA line.

ATR Settings

  • ATR Length: The period used to calculate market volatility.
  • ATR Multiplier: Determines the distance between the stop level and the price.

Backtest Mode

  • Allowed Signals: Filters the backtest results to Long & Short, Long Only, or Short Only.
  • Backtest Start Date: Sets the historical point where the performance calculation begins.
  • Plot Buy & Hold equity?: Toggles the comparative benchmark line.

FAQ

How do I interpret the red and green circles?

Green circles indicate a bullish regime where the volatility stop is below the price, while red circles indicate a bearish regime where the stop is above the price.

Why does the indicator look different in Backtest Mode?

Backtest Mode changes the visual output to an equity curve, allowing you to see the hypothetical growth of a portfolio using the indicator's signals compared to simply holding the asset.

How can I access the Hyperbolic Tangent Volatility Stop?

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.