OPEN-SOURCE SCRIPT

MACD Color Shift

116
//version=5
// Title: MACD with Color Intensity
indicator("MACD Color Shift", overlay = false)

// MACD Inputs
fast_length = input.int(12, "Fast Length", minval=1)
slow_length = input.int(26, "Slow Length", minval=1)
signal_length = input.int(9, "Signal Length", minval=1)

// MACD Calculation
[macdLine, signalLine, hist] = ta.macd(close, fast_length, slow_length, signal_length)

// Calculate momentum (rate of change) to determine color intensity
macdMomentum = ta.change(macdLine)
histMomentum = ta.change(hist)

// Define color conditions
// For Histogram
lightGreen = hist > 0 and histMomentum >= 0
darkGreen = hist > 0 and histMomentum < 0
lightRed = hist < 0 and histMomentum <= 0
darkRed = hist < 0 and histMomentum > 0

// Plot MACD Line
plot(macdLine, "MACD", color=color.blue, linewidth=1)

// Plot Signal Line
plot(signalLine, "Signal", color=color.orange, linewidth=1)

// Plot Histogram with conditional colors
plot(hist, "Histogram", style=plot.style_histogram,
color=lightGreen ? #90EE90 : darkGreen ? #006400 : lightRed ? #FFB6C1 : #8B0000)

// Plot zero line
plot(0, "Zero", color=color.gray, linewidth=1)

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.