instrument {
name = 'AM_IQ BUY-SELL SIGNALS',
short_name = 'BUY-SELL SIGNALS',
overlay = true
}
MaFast_period = input(1, "Ma Fast period", input.integer, 1, 1000, 1)
MaValue = input(5, "Ma Value", input.string_selection, inputs.titles)
MaSlow_period = input(34, "Ma Slow period", input.integer, 1, 1000, 1)
Signal_period = input(4, "Signal period", input.integer, 1, 1000, 1)
input_group {
"Buy",
colorBuy = input { default = "YELLOW", type = input.color },
visibleBuy = input { default = true, type = input.plot_visibility }
}
input_group {
"Sell",
colorSell = input { default = "RED", type = input.color },
visibleSell = input { default = true, type = input.plot_visibility }
}
local titleValue = inputs[MaValue]
// Média móvel rápida
smaFast = sma(titleValue, MaFast_period)
// Média móvel lenta
smaSlow = sma(titleValue, MaSlow_period)
// Cálculo diferencial - série
buffer1 = smaFast - smaSlow
// Cálculo da média ponderada - série
buffer2 = wma(buffer1, Signal_period)
buyCondition = buffer1 > buffer2 and buffer1[1] < buffer2[1]
sellCondition = buffer1 < buffer2 and buffer1[1] > buffer2[1]
plot_shape(
buyCondition,
"30",
shape_style.arrowup,
shape_size.large,
colorBuy,
shape_location.belowbar,
-1,
"BUY",
"YELLOW"
)
plot_shape(
sellCondition,
"30",
shape_style.arrowdown,
shape_size.large,
colorSell,
shape_location.abovebar,
-1,
"SELL",
"RED"
)
instrument {
name = "BEAR SUPORT/REST",
icon = "https://bit.ly/3C8cIFQ",
overlay = true
}
local function a()
local b = make_series()
local c = high[2]
if not get_value(c) then
return b
end
local d = high <= c and high[1] <= c and high[3] <= c and high[4] <= c
b:set(iff(d, c, b[1]))
return b
end
local function e()
local b = make_series()
local c = low[2]
if not get_value(c) then return b end
local d = low >= c and low[1] >= c and low[3] >= c and low[4] >= c
b:set(iff(d, c, b[1]))
return b
end
input_group {
"Color",
color = input { default = "LIME", type = input.color },
width = input { default = 1, type = input.line_width }
}
h = a()
l = e()
hline(h, "High", color, high_width)
hline(l, "Low", color, width)
hline(highest(10