Indicators can only be used in efficient markets, such as BTC or ETH; using them on cryptocurrencies with small market capitalization carries very high risk.
Indicators can only be used in efficient markets, such as BTC or ETH; using them on cryptocurrencies with small market capitalization carries very high risk.
This script is a highly customizable Multi-Timeframe (MTF) Moving Average Convergence Divergence (MACD) indicator for TradingView, written in Pine Script v5. It builds upon the standard MACD by adding extensive visual and functional customization options.
English Explanation
Core Function
The MACD is a trend-following momentum indicator that shows the relationship between two exponential moving averages (EMAs) of a security’s price. This specific script allows you to view the MACD data from a higher timeframe (e.g., the daily MACD) while you are on a lower timeframe chart (e.g., the 1-hour chart). This helps in aligning trades with the longer-term trend.
Key Features
Multi-Timeframe (MTF): The primary feature. You can set the indicator to calculate on any timeframe, independent of the chart's timeframe.
Customizable Moving Averages: You can choose between an Exponential Moving Average (EMA) or a Simple Moving Average (SMA) for both the MACD calculation and the signal line.
Advanced Visual Customization:
Toggle Elements: You can turn on or off the MACD line, signal line, histogram, and crossover dots.
Trend Coloring: The MACD line can be colored based on the trend (e.g., green when MACD is above the signal line, red when below).
Price Bar Highlighting: The price bars on the main chart can be colored to match the MACD trend.
Four-Color Histogram: The histogram uses four different colors to show momentum more clearly:
Growing while above the zero line (e.g., bright green).
Falling while above the zero line (e.g., dark green).
Growing while below the zero line (e.g., dark red).
Falling while below the zero line (e.g., bright red).
Flexible Alert System:
Standard Crossover Alerts: Alerts for when the MACD line crosses above or below the signal line.
Conditional Alerts: Stricter alerts that only trigger on a cross-up if the MACD is above the zero line, or on a cross-down if the MACD is below the zero line.
How to Use It
Add to Chart: Open a chart in TradingView, open the Pine Editor, paste this code, and click "Add to Chart."
Configure Settings: Click the gear icon on the indicator to open its settings.
Indicator TimeFrame: This is the most important setting for MTF. Leave it blank to use the chart's current timeframe, or enter a higher one (e.g., "D" for daily, "4H" for 4-hour).
MACD Parameters: Adjust Fast Length (12), Slow Length (26), and Signal Smoothing (9) as you would for a standard MACD.
MA Type: Choose between "EMA" (default, more responsive) and "SMA."
Show Plots / Color Settings: Customize the look and feel of the indicator. You can change the line widths, colors, and visibility of each component.
How to Interpret:
Signal Line Crossover:
Bullish Cross (Golden Cross): When the MACD line crosses above the Signal line, it's a potential buy signal.
Bearish Cross (Death Cross): When the MACD line crosses below the Signal line, it's a potential sell signal.
Zero Line Crossover:
When the MACD line crosses above the zero line, it indicates that upward momentum is increasing.
When the MACD line crosses below the zero line, it indicates that downward momentum is increasing.
Divergence:
Bullish Divergence: Price makes a new low, but the MACD makes a higher low. This can signal a potential trend reversal to the upside.
Bearish Divergence: Price makes a new high, but the MACD makes a lower high. This can signal a potential trend reversal to the downside.
Setting Up Alerts:
First, in the indicator's Settings panel, go to the "Alerts" group and check the boxes for the alerts you want to enable (e.g., MACD Cross Up).
Next, go to TradingView's main Alerts panel (clock icon on the right).
Click "Create alert." In the "Condition" dropdown, select the indicator (_CM_Ult_MacD_MTF_V2.1).
The alert conditions will be automatically populated based on the code. Choose the one you need.
Set "Options" to "Once Per Bar Close" for best results, as the script is designed for this.
Click "Create."
Chinese Explanation
Core Function
This is a highly customizable Multi-Timeframe (MTF) Smooth Moving Average Convergence Divergence (MACD) indicator written in Pine Script v5 for TradingView. It adds a large number of visual and functional customization options based on the standard MACD.
The MACD is a trend-following momentum indicator that shows the relationship between two exponential moving averages (EMAs) of a security’s price. This specific script allows you to view the MACD data from a higher timeframe (e.g., the daily MACD) while you are on a lower timeframe chart (e.g., the 1-hour chart). This helps in aligning trades with the longer-term trend.
Key Features
Multi-Timeframe (MTF): This is the core function. You can set the indicator to calculate on any timeframe without switching the current chart's timeframe.
Customizable Moving Average Types: You can choose between Exponential Moving Average (EMA) or Simple Moving Average (SMA) for both the MACD calculation and the signal line.
Advanced Visual Customization:
Toggle Elements: You can freely turn on or off the MACD line, signal line, histogram, and crossover dots.
Trend Coloring: The MACD line can be colored based on the trend (e.g., green when MACD is above the signal line, red when below).
Price Bar Highlighting: The price bars on the main chart can be colored to match the MACD trend.
Four-Color Histogram: The histogram uses four different colors to show momentum more clearly:
Above the zero line and growing (e.g., bright green).
Above the zero line but contracting (e.g., dark green).
Below the zero line but growing (e.g., dark red).
Below the zero line but contracting (e.g., bright red).
Flexible Alert System:
Standard Crossover Alerts: Set alerts for when the MACD line crosses above or below the signal line.
Conditional Crossover Alerts: Stricter alerts. Only trigger bullish alerts if the MACD crosses above the signal line while above the zero line, or trigger bearish alerts if the MACD crosses below the signal line while below the zero line.
How to Use
Add to Chart: Open a chart in TradingView, open the Pine Editor, paste this code, and click "Add to Chart."
Configure Settings: Click the gear icon next to the indicator name to open its settings panel.
Indicator TimeFrame: This is the most important setting for MTF. Leave it blank to use the chart's current timeframe, or enter a higher one (e.g., "D" for daily, "4H" for 4-hour).
MACD Parameters: Adjust Fast Length (12), Slow Length (26), and Signal Smoothing (9) as you would for a standard MACD.
MA Type: Choose between "EMA" (default, more responsive) and "SMA."
Show Plots / Color Settings: Customize the look and feel of the indicator. You can change the line widths, colors, and visibility of each component.
How to Interpret:
Signal Line Crossover:
Bullish Cross: When the MACD line (fast line) crosses above the signal line (slow line), it's a potential buy signal.
Bearish Cross: When the MACD line crosses below the signal line, it's a potential sell signal.
Zero Line Crossover:
When the MACD line crosses up through the zero line, it indicates that upward momentum is increasing.
When the MACD line crosses down through the zero line, it indicates that downward momentum is increasing.
Divergence:
Bullish Divergence: Price makes a new low, but the MACD does not make a new low. This may signal a potential trend reversal to the upside.
Bearish Divergence: Price makes a new high, but the MACD does not make a new high. This may signal a potential trend reversal to the downside.
Set Alerts:
First, in the indicator's Settings panel, find the "Alerts" group and check the boxes for the alerts you want to enable (e.g., MACD Cross Up).
Then, open the Alerts panel on the right sidebar of TradingView (clock icon).
Click "Create Alert." In the "Condition" dropdown, select the indicator (_CM_Ult_MacD_MTF_V2.1).
The alert conditions will be automatically populated based on the code. Choose the one you need.
Set "Options" to "Once Per Bar Close" for best results, as the script is designed for this.
Click "Create."



