dashed

MACD Colors

147
This adds visual cue for when MACD histogram bars is decreasing when above the zero-line, and increasing when below the zero-line.

Based on:
סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יכולים להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אך שימוש חוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.

רוצה להשתמש בסקריפ זה בגרף?
//@version=2
study("MACD Colors", overlay = false)

// This adds visual cue for when MACD histogram bars is decreasing when above the zero-line, and
// when increasing when below the zero-line.
// 
// Based on: https://www.tradingview.com/script/4IYKX938-MACD-4C/

fastMA = input(title="Fast Length", type = integer, defval = 12)
slowMA = input(title="Slow Length", type = integer, defval = 26)
src = input(title="Source", type=source, defval=close)
signalSmooth = input(title="Signal smoothing", type = integer, defval = 9)
sma_macd = input(title="Simple MA (for MACD line)", type = bool, defval = false)
sma_signal = input(title="Simple MA (for signal line)", type = bool, defval = false)

MACDLine =  if sma_macd
    sma(src, fastMA) - sma(src, slowMA)
else 
    ema(src, fastMA) - ema(src, slowMA)
    
SignalLine = if sma_signal
    sma(MACDLine, signalSmooth)
else
    ema(MACDLine, signalSmooth)

MACDHistogram = MACDLine - SignalLine

plotColor = if MACDHistogram > 0
    MACDHistogram > MACDHistogram[1] ? lime : green
else 
    MACDHistogram < MACDHistogram[1] ? maroon : red

plot(MACDLine, style = line, color = blue)
plot(SignalLine, style = line, color = orange)
plot(MACDHistogram, style = columns, color = plotColor)
plot(0, title = "Zero line", linewidth = 1, color = gray)