Güncellendi

[blackcat] L1 Another Improved MACD Indicator

6 338
Level: 1

Background

The MACD is a superior derivative of moving average crossovers and was developed by Gerald Appel in 1979 as a market timing tool. MACD uses two exponential moving averages with different bar periods, which are then subtracted to form what Mr. Appel calls the Fast Line. A 9-period moving average of the fast line creates the slow line.

Function

[blackcat] L1 Another Improved MACD Indicator improves MACD histogram by customized an algorithm and add three levels of long entry alerts derived from ema ().

Key Signal

diff --> classic MACD diff fast line in white
dea --> classic MACD dea slow line in yellow
macd --> classic difference histogram,but I did not use it directly in the plot.
macd1 --> ema3 of macd

Pros and Cons

Pros:

1. more clear sub level trend change with new histograms


Cons:

1. need sophisticated knowledge of MACD to use this well
2. this still requires a lot of MACD experience to obtain reliable trading signals


Remarks

Another improved MACD on histogram

Readme

In real life, I am a prolific inventor. I have successfully applied for more than 60 international and regional patents in the past 12 years. But in the past two years or so, I have tried to transfer my creativity to the development of trading strategies. Tradingview is the ideal platform for me. I am selecting and contributing some of the hundreds of scripts to publish in Tradingview community. Welcome everyone to interact with me to discuss these interesting pine scripts.

The scripts posted are categorized into 5 levels according to my efforts or manhours put into these works.

Level 1 : interesting script snippets or distinctive improvement from classic indicators or strategy. Level 1 scripts can usually appear in more complex indicators as a function module or element.

Level 2 : composite indicator/strategy. By selecting or combining several independent or dependent functions or sub indicators in proper way, the composite script exhibits a resonance phenomenon which can filter out noise or fake trading signal to enhance trading confidence level.

Level 3 : comprehensive indicator/strategy. They are simple trading systems based on my strategies. They are commonly containing several or all of entry signal, close signal, stop loss, take profit, re-entry, risk management, and position sizing techniques. Even some interesting fundamental and mass psychological aspects are incorporated.

Level 4 : script snippets or functions that do not disclose source code. Interesting element that can reveal market laws and work as raw material for indicators and strategies. If you find Level 1~2 scripts are helpful, Level 4 is a private version that took me far more efforts to develop.

Level 5 : indicator/strategy that do not disclose source code. private version of Level 3 script with my accumulated script processing skills or a large number of custom functions. I had a private function library built in past two years. Level 5 scripts use many of them to achieve private trading strategy.
Sürüm Notları
OVERVIEW

The [blackcat] L1 Another Improved MACD Indicator provides an advanced interpretation of the classic MACD oscillator with enhanced visualization tools. This script combines exponential moving averages (EMAs), dynamic coloring schemes, and real-time buy/sell signal markers to improve trading decision-making.

FEATURES

Adjustable input parameters:
• Customizable fast/EMA period
• Customizable slow/EMA period
• Configurable signal line period

Enhanced calculation methodology:
✓ Uses EMA-based core components
✓ Includes unique MACD_Signal_EMA (3-period EMA of histogram)
✓ Generates distinct histogram display with embedded trend analysis

Interactive visualization features:
✅ Color-coded MACD-Signal overlap zones
✅ Dynamic histogram coloring relative to MACD_Signal_EMA
✅ Real-time B/S arrow labels for trade confirmation

HOW TO USE

Adjust input parameters using the settings panel
Analyze main MACD-line vs signal-line relationship shown in filled area
Monitor histogram trends compared to MACD_Signal_EMA:
→ Red = bullish divergence dominance
→ Green = bearish divergence dominance
→ Yellow = neutral/trend uncertainty phase
Act on labeled buy ("B")/sell ("S") signals appearing during crossovers

LIMITATIONS

• Lag potential due to multi-layered EMA calculations
• Overlap warnings when combining with price-action strategies
• Requires volatility adjustments for optimal performance in trending markets

NOTES

• All signals require prior bar validation for accuracy
• Color thresholds optimized for default timeframes (adjustments may needed for sub-minute charts)
Sürüm Notları
█ OVERVIEW

An enhanced MACD oscillator that pairs the classic crossover system with a signal state machine, volatility-scaled take-profit/stop-loss levels and built-in alerts. B/S labels, exit markers, a live dashboard and four one-click alert conditions make it ready for real-time signal monitoring.

█ CONCEPTS

The indicator builds on the classic MACD framework (ta.ema-based fast/slow lines, signal line, histogram) and adds a position-aware signal layer:

 • Improved histogram: the MACD histogram is scaled by a configurable multiplier and smoothed with a short EMA, which is then used to grade momentum strength through three colors
 • Signal state machine: every crossover is routed through a position state (long / flat / short), so entries, exits and stop-and-reverse flips are explicit and never contradictory
 • Volatility-scaled risk reference: ATR-based take-profit and stop-loss levels are computed for the active signal and drawn on the main chart

█ HOW TO USE

1 — Add the script to your chart; it loads in a separate pane below price with the default 12/26/9 MACD settings
2 — Read B labels as bullish crossover entries and S labels as bearish crossover entries; when a crossover flips an open position, the label shows the combined action (XS+B or XL+S)
3 — Optional: raise Cooldown Bars to suppress signals firing too close together, and tune the ATR multipliers to your instrument's volatility
4 — Create alerts from the four built-in alert conditions (long entry, short entry, long exit, short exit); "Once Per Bar Close" is recommended

Input Parameters
 • Fast EMA Period (12): length of the fast EMA used in the MACD line
 • Slow EMA Period (26): length of the slow EMA used in the MACD line
 • Signal Line Period (9): EMA smoothing of the MACD line
 • Histogram Multiplier (2.0): scaling factor of the histogram (V1 default 2)
 • Histogram Smoothing EMA Length (3): smoothing applied to the histogram for momentum grading
 • Enable Short Signals (true): turn off for long-only signal reading
 • Cooldown Bars (0 = off): minimum bar spacing between signals
 • Enable ATR TP/SL Levels (true): master switch for the risk reference layer
 • Draw TP/SL Lines on Main Chart (true): dashed take-profit/stop lines over price
 • ATR Length (14): lookback of the ATR used for TP/SL distances
 • Stop Loss / Take Profit (2.0 / 3.0 xATR): distance multipliers from the entry close
 • Position Background Tint / Show Dashboard (true): visual toggles

█ FEATURES

 • Four alertcondition channels plus a dynamic alert() message with price; alerts fire once per bar close, so confirmed signals never repaint
 • Stop-and-reverse aware labels: B, S, XL, XS and combined XS+B / XL+S tags
 • ATR-scaled TP/SL dashed lines projected on the main chart from the entry bar
 • Live dashboard: position state, MACD/signal values, histogram, ATR and current TP/SL levels
 • Position state, stop and target values also exposed in the data window for screening

█ SIGNALS

Visual Elements
 • B (lime, up label): bullish crossover — long entry
 • S (red, down label): bearish crossover — short entry
 • XS+B / XL+S: reverse crossover closing the old position and opening the new one on the same bar
 • XL / XS (orange cross): position closed by the opposite crossover (shown when short signals are disabled)
 • Background tint: light green while long, light red while short
 • Histogram colors (red / green / yellow): momentum strength relative to the smoothed histogram — original V1 semantics preserved

█ IMPLEMENTATION NOTES

Open-source. Built with ta.ema, ta.crossover / ta.crossunder and ta.atr; there are no request.security calls, so nothing depends on higher-timeframe data. A position state machine (var int posState) allows at most one state transition per bar. The TP/SL layer uses line.new(force_overlay = true), which requires a literal, so the drawing toggle gates the calls instead of the parameter. The core signal idea:

Pine Script®


█ LIMITATIONS

 • Trend-following by nature: expect whipsaws in flat, ranging markets — the cooldown input helps but cannot eliminate them
 • TP/SL levels are informational references drawn by an indicator, not exchange orders; they do not manage real positions
 • Signals are most reliable at bar close; intrabar the crossover can un-cross before confirmation
 • No performance claims are made — validate on your own symbols and timeframes

█ NOTES

 • V2 polish of blackcat's "Another Improved MACD Indicator": identical MACD math (12/26/9, histogram x2, smoothing 3 by default) with the signal, risk and alert layers added
 • All new layers are switchable; with cooldown at 0 the B/S label sequence matches the original V1

════════════════════════════════════════════════════════════════════════
For questions or feedback, please use the comments section below.
Feel free to use and modify — attribution appreciated.

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.