MACD and EMA Indicator Script

0% found this document useful (0 votes)
155 views1 page
This document defines an indicator called "Relanpago" that calculates the MACD indicator and plots candlestick charts with color bars based on MACD and EMA values. It takes in user-defined i…

Uploaded by

jdsjdndudjdu
  • MACD Trading Algorithm Script

instrument {

name = "Relanpago",
overlay = " true",
}
input_group {
"MACD",
"Slow and fast EMA periods, used in MACD calculation",
fast = input (12, "[Link] period", [Link], 1, 250),
slow = input (26, "[Link] period", [Link], 1, 250)
}
input_group {
"[Link]-line",
"Reference signal series period",
signal_period = input (9, "[Link]", [Link], 1, 250)
}
input_group {
"[Link]",
ema_period = input (13, "[Link]", [Link], 1, 250)
}
input_group {
"[Link]",
positive = input { default = "#2CAC40", type = [Link] },
neutral = input { default = "#C7CAD1", type = [Link] },
negative = input { default = "#DB4931", type = [Link] },
}
fastMA = ema(close, fast)
slowMA = ema(close, slow)
macd = fastMA - slowMA
signal = sma(macd, signal_period)
hist = macd - signal
ema13 = ema (close, ema_period)
local bar_color
if ema13 > ema13 [1] and hist > hist [1] then
bar_color = positive
elseif ema13 < ema13 [1] and hist < hist [1] then
bar_color = negative
else
bar_color = neutral
end
plot_candle (open, high, low, close, "ES", bar_color)

instrument {
    name = "Relanpago",
    overlay = " true",
}
input_group {
    "MACD",
    "Slow and fast EMA periods, used

You might also like