OPEN-SOURCE SCRIPT

Mean Trend Oscillator

Updated
Mean Trend Oscillator

The Mean Trend Oscillator offers an original approach to trend analysis by integrating multiple technical indicators, using statistic to get a probable signal, and dynamically adapting to market volatility.

This tool aggregates signals from four popular indicators—Relative Strength Index (RSI), Simple Moving Average (SMA), Exponential Moving Average (EMA), and Relative Moving Average (RMA)—and adjusts thresholds using the Average True Range (ATR). By using this, we can use Statistics to aggregate or take the average of each indicators signal. Mathematically, Taking an average of these indicators gives us a better probability on entering a trending state.

By consolidating these distinct perspectives, the Mean Trend Oscillator provides a comprehensive view of market direction, helping traders make informed decisions based on a broad, data-driven trend assessment. Traders can use this indicator to enter long spot or leveraged positions. The Mean Trend Oscillator is intended to be use in long term trending markets. Scalping MUST NOT be used with this indicator. (This indicator will give false signals when the Timeframe is too low. The best intended use for high-quality signals are longer timeframes).

The current price of a beginning trend series may tell us something about the next move. Thus, the Mean Trend Oscillator allows us to spot a high probability trending market and potentially exploit this information enter long or shorts strategy. (again, this indicator will give false signals when the Timeframe is too low. The best intended use for high-quality signals are longer timeframes).

Concept and Calculation and Inputs
The Mean Trend Oscillator calculates a “net trend” score as follows:
  1. RSI evaluates market momentum, identifying overbought and oversold conditions, essential for confirming trend direction.
  2. SMA, EMA, and RMA introduce varied smoothing methods to capture short- to medium-term trends, balancing quick price changes with smoothed averages.
  3. ATR-Enhanced Thresholds: ATR is used as a dynamic multiplier, adjusting each indicator’s thresholds to current volatility levels, which helps reduce noise in low-volatility conditions and emphasizes significant signals when volatility spikes.
  4. Length could be used to adjust how quickly each indicator can more or how slower each indicator can be.
  5. Time Coherency for Inputs: Each indicator must be calculated where each signal is relatively around the same area.

For example:
snapshot
Simply:
SMA, RMA, EMA, and RSI enters long around each intended trend period. Doesn't have to be perfect, but the indicators all enter long around there.

Each indicator contributes a score (+1 for bullish and -1 for bearish), and these scores are averaged to generate the final trend score:
  • A positive score, shown as a green line, suggests bullish conditions.
  • A negative score, indicated by a red line, signifies bearish conditions.
  • Thus, giving us a signal to long or short.

How to Use the Mean Trend Oscillator
This indicator’s output is straightforward and can fit into various trading strategies:
  • Bullish Signal: A green line shows that the trend is bullish, based on a positive average score across the indicators, signaling a consideration of longing an asset.
  • Bearish Signal: A red line indicates bearish conditions, with an overall negative trend score, signaling a consideration to shorting an asset.

By aggregating these indicators, the Mean Trend Oscillator helps traders identify strong trends while filtering out minor fluctuations, making it a versatile tool for both short- and long-term analysis. This multi-layered, adaptive approach to trend detection sets it apart from traditional single-indicator trend tools.
Release Notes
Mean Trend Oscillator Update Overview
The latest update to the Mean Trend Oscillator enhances its functionality and visualization features, making it more versatile and user-friendly. Here are the key improvements:

Key Updates:

  • New Plotting Options for Moving Averages and RSI:
  • Toggle Options for SMA, RMA, EMA, and RSI: New Plot SMA, Plot RMA, Plot EMA, and Plot RSI settings allow users to selectively plot each moving average and RSI line. This flexibility helps align indicators within the same timeframe, reducing false signals and providing better trend coherence.
  • Enhanced Visibility for Trend Coherency: By allowing users to view or hide specific moving averages, this update supports more refined analysis and helps align entries more precisely based on preferred trend signals.

    Customizable ATR-Adjusted Moving Averages:
  • Each of the moving averages (SMA, RMA, EMA) and the RSI now have ATR-adjusted conditions that determine long and short positions. This is achieved by comparing the source (typically the close price) with the average plus or minus ATR, which adds a layer of volatility filtering to the indicator’s trend signals.

    Dynamic Color Coding:
  • Color-Coded Moving Averages and RSI: The SMA, RMA, EMA, and RSI lines now use dynamic color coding. When the source is above a moving average, the line turns magenta, indicating a potential uptrend; when it is below, it turns aqua, signaling a potential downtrend. This color scheme visually reinforces the trend signals and highlights alignment between price and moving averages.
  • Trend-Driven Candle Colors: The indicator includes a new plotcandle function, which color-codes candles based on the calculated trendaverage direction. Candles are green for uptrends and red for downtrends, providing a more intuitive visual representation of the trend on the chart.
    Improved RSI Plotting:
  • Center Line for RSI: When the RSI plot is enabled, a gray dashed horizontal line at 50 marks the threshold for bullish/bearish signals, helping users quickly identify when the RSI crosses into bullish or bearish zones.

    Enhanced Trend Calculation and Plotting:
  • Mean Trend Average Calculation: The core calculation of the indicator, trendaverage, is improved with a more accurate count of indicators in each direction. This calculation now accounts for the cumulative trend signals from all moving averages and the RSI, offering a balanced view of the prevailing trend.
    Single Trend Plot with Enhanced Visibility: The trendaverage line is plotted as either green or red, based on the trend direction, and is displayed prominently on the oscillator chart for clear trend visibility.


Summary
This update makes the Mean Trend Oscillator a more comprehensive tool for analyzing market trends by incorporating adjustable plots for popular moving averages and RSI, dynamic color-coded visuals, and volatility-based trend filtering. These enhancements provide traders with more granular control and visual cues, helping them make more informed trading decisions with improved clarity and coherence.
OscillatorsstatisticsTrend Analysis

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer