The indicator combines Exponential Moving Averages (EMA), Moving Average Convergence Divergence (MACD), and Relative Strength Index (RSI) to determine the trend direction on various timeframes: 15 minutes (15M), 30 minutes (30M), 1 hour (1H), 4 hours (4H), 1 day (1D), and 1 week (1W).

**EMA Trend**: The script calculates two EMAs for each timeframe: a fast EMA and a slow EMA. If the fast EMA is greater than the slow EMA, the trend is considered Bullish; if the fast EMA is less than the slow EMA, the trend is considered Bearish.

**MACD Trend**: The script calculates the MACD line and the signal line for each timeframe. If the MACD line is above the signal line, the trend is considered Bullish; if the MACD line is below the signal line, the trend is considered Bearish.

**RSI Trend**: The script calculates the RSI for each timeframe. If the RSI value is above a specified Bullish level, the trend is considered Bullish; if the RSI value is below a specified Bearish level, the trend is considered Bearish. If the RSI value is between the Bullish and Bearish levels, the trend is Neutral, and no arrow is displayed.

**Dashboard Display**:

The indicator prints arrows on the dashboard to represent Bullish (▲ Green) or Bearish (▼ Red) trends for each timeframe.

You can easily adapt the Dashboard colors (Inputs > Theme) for visibility depending on whether you're using a Light or Dark theme for TradingView.

**Usage**:

You can adjust the indicator's settings such as theme (Dark or Light), EMA periods, MACD parameters, RSI period, and Bullish/Bearish levels to adapt it to your specific trading strategies and preferences.

**Disclaimer**:

This indicator is designed to quickly help you identify the trend direction on multiple timeframes and potentially make more informed trading decisions.

You should consider it as an extra tool to complement your strategy, but you should not solely rely on it for making trading decisions.

Always perform your own analysis and risk management before executing trades.

The indicator will only show a Dashboard. The EMAs, RSI and MACD you see on the chart image have been added just to demonstrate how the script works.

**DETAILED SCRIPT EXPLANATION**

INPUTS:

*theme*: Allows selecting the color theme (options: "Dark" or "Light").

*emaFastPeriod*: The period for the fast EMA.

*emaSlowPeriod*: The period for the slow EMA.

*macdFastLength*: The fast length for MACD calculation.

*macdSlowLength*: The slow length for MACD calculation.

*macdSignalLength*: The signal length for MACD calculation.

*rsiPeriod*: The period for RSI calculation.

*rsiBullishLevel*: The level used to determine Bullish RSI condition, when RSI is above this value. It should always be higher than rsiBearishLevel.

*rsiBearishLevel*: The level used to determine Bearish RSI condition, when RSI is below this value. It should always be lower than rsiBullishLevel.

CALCULATIONS:

- The script calculates EMAs on multiple timeframes (15-minute, 30-minute, 1-hour, 4-hour, daily, and weekly) using the
*request.security()*function.

- Similarly, the script calculates MACD values (
*macdLine*,*signalLine*) on the same multiple timeframes using the*request.security()*function along with the*ta.macd()*function.

- RSI values are also calculated for each timeframe using the
*request.security()*function along with the*ta.rsi()*function.

- The script then determines the EMA trends for each timeframe by comparing the fast and slow EMAs using simple boolean expressions.

- Similarly, it determines the MACD trends for each timeframe by comparing the MACD line with the signal line.

- Lastly, it determines the RSI trends for each timeframe by comparing the RSI values with the Bullish and Bearish RSI levels.

PLOTTING AND DASHBOARD:

- Color codes are defined based on the EMA, MACD, and RSI trends for each timeframe. Green for Bullish, Red for Bearish.

- A dashboard is created using the
*table.new()*function, displaying the trend information for each timeframe with arrows representing Bullish or Bearish conditions.

- The dashboard will appear in the top-right corner of the chart, showing the Bullish and Bearish trends for each timeframe (15M, 30M, 1H, 4H, 1D, and 1W) based on EMA, MACD, and RSI analysis. Green arrows represent Bullish trends, red arrows represent Bearish trends, and no arrows indicate Neutral conditions.

**INFO ON USED INDICATORS:**

1 — EXPONENTIAL MOVING AVERAGE (EMA)

The Exponential Moving Average (EMA) is a type of moving average (MA) that places a greater weight and significance on the most recent data points.

The EMA is calculated by taking the average of the true range over a specified period. The true range is the greatest of the following:

- The difference between the current high and the current low.

- The difference between the previous close and the current high.

- The difference between the previous close and the current low.

The formula for calculating EMA is as follows:

- Compute the Simple Moving Average (SMA).

- Calculate the multiplier for weighting the EMA.

- Calculate the current EMA using the following formula:

`EMA = Closing price x multiplier + EMA (previous day) x (1-multiplier)`

2 — MOVING AVERAGE CONVERGENCE DIVERGENCE (MACD)

The Moving Average Convergence Divergence (MACD) is a popular trend-following momentum indicator used in technical analysis. It helps traders identify changes in the strength, direction, momentum, and duration of a trend in a financial instrument's price.

The MACD is calculated by subtracting a longer-term Exponential Moving Average (EMA) from a shorter-term EMA. The most commonly used time periods for the MACD are 26 periods for the longer EMA and 12 periods for the shorter EMA. The difference between the two EMAs creates the main MACD line.

Additionally, a Signal Line (usually a 9-period EMA) is computed, representing a smoothed version of the MACD line. Traders watch for crossovers between the MACD line and the Signal Line, which can generate buy and sell signals. When the MACD line crosses above the Signal Line, it generates a bullish signal, indicating a potential uptrend. Conversely, when the MACD line crosses below the Signal Line, it generates a bearish signal, indicating a potential downtrend.

In addition to the MACD line and Signal Line crossovers, traders often look for divergences between the MACD and the price chart. Divergence occurs when the MACD is moving in the opposite direction of the price, which can suggest a potential trend reversal.

3 — RELATIVE STRENGHT INDEX (RSI):

The Relative Strength Index (RSI) is another popular momentum oscillator used by traders to assess the overbought or oversold conditions of a financial instrument. The RSI ranges from 0 to 100 and measures the speed and change of price movements.

The RSI is calculated based on the average gain and average loss over a specified period, commonly 14 periods. The formula involves several steps:

- Calculate the average gain over the specified period.

- Calculate the average loss over the specified period.

- Calculate the relative strength (RS) by dividing the average gain by the average loss.

- Calculate the RSI using the following formula: RSI = 100 - (100 / (1 + RS))

The RSI oscillates between 0 and 100, where readings above 70 are considered overbought, suggesting that the price may have risen too far and could be due for a correction. Readings below 30 are considered oversold, suggesting that the price may have dropped too much and could be due for a rebound.

Traders often use the RSI to identify potential trend reversals. For example, when the RSI crosses above 30 from below, it may indicate the start of an uptrend, and when it crosses below 70 from above, it may indicate the start of a downtrend. Additionally, traders may look for bullish or bearish divergences between the RSI and the price chart, similar to the MACD analysis, to spot potential trend changes.

Release Notes:

Added 5 minute trend for anyone who wants to use this on shorter timeframes.

Added CCI as a fourth trend indicator.

When CCI > 0 for a given timeframe, the indicator will print a Bullish signal.

When CCI < 0 for a given timeframe, the indicator will print a Bearish signal.

When CCI > 0 for a given timeframe, the indicator will print a Bullish signal.

When CCI < 0 for a given timeframe, the indicator will print a Bearish signal.

- Added
*cciPeriod*under Inputs to customize the CCI Period

- Added CCI calculation for all timeframes

- Added CCI trend determination for all timeframes

- Added CCI coloring rules for all timeframes

- Added 1 row to the table for CCI Bullish and Bearish signals

**MAJOR UPDATE**

The strategy will now print Bullish (Green) warning signs (⚠) for RSI and CCI when they are above the Overbought levels you defined.

The strategy will now print Bearish (Red) warning signs (⚠) for RSI and CCI when they are below the Oversold levels you defined.

CHANGE LIST

1 — Inputs:

Added rsiOverbought and rsiOversold inputs to define RSI Overbought and RSI Oversold levels

Added cciOverbought and cciOversold inputs to define CCI Overbought and CCI Oversold levels

2 — Trend Determination:

Calculating isRSIBullSign, isRSIBearSign and isRSIWarning to determine whether to print a Bullish, Bearish or Warning sign for RSI

Calculating isCCIBullSign, isCCIBeaCCIgn and isCCIWarning to determine whether to print a Bullish, Bearish or Warning sign for CCI

3 — Dashboard:

The indicator will now print ⚠ for Overbought conditions, ▲ for Bullish trend, ▼ for Bearish trend

The color is still determined by the Bullish (Green) or Bearish (Red) trend, for all symbols

**Update: Added Volume**

Now, the indicator also calculates Volume and a Volume SMA for all timeframes, to show how reliable the relevant signals are.

In general, whenever volume is low, all signals should be considered less reliable.

Changes:

- Changed the short name of the indicator to MTTD (Multi-Timeframe Trend Detector). "D" was missing.

- Added
*volumePeriod*under Inputs, used to calculate the Volume SMA on all timeframes.

- Volume is requested for all timeframes.
*NOTE: Because of the limitation of 40 security requests in Pine Script, Volume for 15M and 30M has to be calculated with an SMA of the 5M Volume.*

- Volume SMA is calculated using the period you define under Inputs.

- Volume is checked against Volume SMA to determine the color of the signals to be printed.

- Added a new VOL row to the table for Volume.

- A blue square (■) is be printed if Volume > Volume SMA.

- A yellow square (■) is be printed if Volume < Volume SMA.