OPEN-SOURCE SCRIPT

Trend Analyzer

The Trend Analyzer is designed to help traders identify and analyze market trends. Here's a simple explanation of its logic:

Main Features
  1. Customizable Moving Average: The indicator plots a moving average on the chart. Users can choose from various types (SMA, EMA, WMA, VWMA, HMA, SMMA, TMA) and set the period. This flexibility allows traders to adapt the indicator to different trading styles and timeframes.
  2. Trend Detection: It determines whether the current price is above or below the moving average, providing a clear visual representation of the current trend direction.
  3. Sequence Counter: The indicator counts consecutive candles above or below the moving average. This feature helps traders identify trend strength and persistence, which can be crucial for timing entries and exits.
  4. Statistical Analysis: It calculates probabilities for the next candle's direction based on historical data. This unique feature gives traders a statistical edge in predicting short-term price movements.
  5. Visual Candle Counter: An optional feature that displays the number of consecutive candles above or below the moving average directly on the chart, enhancing visual analysis.

How It Works
  1. The indicator continuously tracks the position of price relative to the chosen moving average.
  2. It maintains a count of how many candles in a row have been above or below the moving average.
  3. For each sequence length, it records historical data on how often the trend continued or reversed in the past.
  4. This historical data is used to calculate probabilities for the next candle's direction, providing a statistical insight into potential price movements.
  5. The indicator displays this information directly on the chart, allowing for quick and easy interpretation.

Practical Applications
  • Trend Confirmation: Use the indicator to confirm the strength and direction of current trends.
  • Entry and Exit Signals: The sequence counter and probability calculations can help in timing trades more effectively.
  • Risk Management: Understanding the statistical likelihood of trend continuation can aid in setting appropriate stop-loss and take-profit levels.
  • Market Analysis: The indicator provides valuable insights into market behavior and can be used for both short-term and long-term analysis.


While the Trend Analyzer provides valuable insights based on historical data and statistical analysis, it's important to remember that past performance does not guarantee future results. The financial markets are complex and influenced by numerous factors. This indicator should be used as part of a comprehensive trading strategy and not as a sole decision-making tool. Always practice proper risk management and consider seeking advice from financial professionals before making investment decisions.
Exponential Moving Average (EMA)moving_averageSimple Moving Average (SMA)Trend 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?


The trend is your friend, until it's not...
Also on:

Disclaimer