已更新
MACD Signal (Acht)

Script Description: MACD Signal
This script is a modified version of the classic MACD (Moving Average Convergence Divergence) indicator. Custom conditions have been added to generate more precise buy (long) and sell (short) signals using the EMA9, EMA20, and EMA200 moving averages.
Main Components of the Indicator:
MACD line (fast EMA12 – slow EMA26)
Signal line (EMA9 of MACD)
MACD histogram (difference between MACD and signal line), colored in standard shades: green shades when the histogram is positive, red shades when negative.
Zero line (horizontal line at 0).
Additional Calculations:
EMA9, EMA20, EMA200 based on the closing price (close). The periods of these moving averages can be adjusted in the input parameters.
Signal Conditions:
Long Signal (buy) – green vertical line:
Closing price above EMA200 (global uptrend).
EMA9 crosses above EMA20 (crossover) – entry point.
On the previous bar, the MACD lines (macd and signal) were below zero – confirmation that the indicator is emerging from the "bearish" zone.
Short Signal (sell) – red vertical line:
Closing price below EMA200 (global downtrend).
EMA9 crosses below EMA20 (crossunder) – entry point.
On the previous bar, the MACD lines (macd and signal) were above zero – confirmation that the indicator is emerging from the "bullish" zone.
Signal Visualization:
When conditions are met on the current bar, a vertical line is drawn, spanning from the minimum to the maximum MACD value over the last 100 bars. This makes the signal clearly visible across the entire height of the indicator.
Line color: green for long, red for short. Line width is 2.
Lines older than 200 bars are automatically deleted to prevent chart clutter.
Input Parameters (adjustable):
Source – data source for MACD (default: close).
Fast length – period of the fast EMA (default: 12).
Slow length – period of the slow EMA (default: 26).
Signal length – period of the signal line (default: 9).
Oscillator MA type / Signal MA type – types of moving averages for MACD and signal (EMA or SMA).
EMA 9 length, EMA 20 length, EMA 200 length – periods of the additional EMAs for entry conditions (default: 9, 20, 200).
Built-in Alert Conditions:
Rising to falling – triggers when the histogram transitions from positive to negative (green → red).
Falling to rising – triggers when the histogram transitions from negative to positive (red → green).
Notes:
All EMA9/EMA20 crossovers are calculated globally on each bar, eliminating compilation errors and ensuring correct indicator operation.
Signals do not repaint, as they use only current and previous values.
The code fully complies with Pine Script v6 and contains no errors.
This indicator helps identify entry points in the direction of the global trend (determined by EMA200) with confirmation from the MACD, enhancing signal reliability.
This script is a modified version of the classic MACD (Moving Average Convergence Divergence) indicator. Custom conditions have been added to generate more precise buy (long) and sell (short) signals using the EMA9, EMA20, and EMA200 moving averages.
Main Components of the Indicator:
MACD line (fast EMA12 – slow EMA26)
Signal line (EMA9 of MACD)
MACD histogram (difference between MACD and signal line), colored in standard shades: green shades when the histogram is positive, red shades when negative.
Zero line (horizontal line at 0).
Additional Calculations:
EMA9, EMA20, EMA200 based on the closing price (close). The periods of these moving averages can be adjusted in the input parameters.
Signal Conditions:
Long Signal (buy) – green vertical line:
Closing price above EMA200 (global uptrend).
EMA9 crosses above EMA20 (crossover) – entry point.
On the previous bar, the MACD lines (macd and signal) were below zero – confirmation that the indicator is emerging from the "bearish" zone.
Short Signal (sell) – red vertical line:
Closing price below EMA200 (global downtrend).
EMA9 crosses below EMA20 (crossunder) – entry point.
On the previous bar, the MACD lines (macd and signal) were above zero – confirmation that the indicator is emerging from the "bullish" zone.
Signal Visualization:
When conditions are met on the current bar, a vertical line is drawn, spanning from the minimum to the maximum MACD value over the last 100 bars. This makes the signal clearly visible across the entire height of the indicator.
Line color: green for long, red for short. Line width is 2.
Lines older than 200 bars are automatically deleted to prevent chart clutter.
Input Parameters (adjustable):
Source – data source for MACD (default: close).
Fast length – period of the fast EMA (default: 12).
Slow length – period of the slow EMA (default: 26).
Signal length – period of the signal line (default: 9).
Oscillator MA type / Signal MA type – types of moving averages for MACD and signal (EMA or SMA).
EMA 9 length, EMA 20 length, EMA 200 length – periods of the additional EMAs for entry conditions (default: 9, 20, 200).
Built-in Alert Conditions:
Rising to falling – triggers when the histogram transitions from positive to negative (green → red).
Falling to rising – triggers when the histogram transitions from negative to positive (red → green).
Notes:
All EMA9/EMA20 crossovers are calculated globally on each bar, eliminating compilation errors and ensuring correct indicator operation.
Signals do not repaint, as they use only current and previous values.
The code fully complies with Pine Script v6 and contains no errors.
This indicator helps identify entry points in the direction of the global trend (determined by EMA200) with confirmation from the MACD, enhancing signal reliability.
版本注释
update版本注释
update版本注释
update免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。