instrument {
name = 'WINDICADOR 5.0',
short_name = 'super',
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(5,"Signal period",input.integer,1,1000,1)
input_group {
"Compra",
colorBuy = input { default = "green", type = input.color },
visibleBuy = input { default = true, type = input.plot_visibility }
}
input_group {
"Venda",
colorSell = input { default = "red", type = input.color },
visibleSell = input { default = true, type = input.plot_visibility }
}
local titleValue = inputs[MaValue]
-- mdia mvel linear rpida
smaFast = sma(titleValue, MaFast_period)
-- mdia mvel linear devagar
smaSlow = sma(titleValue, MaSlow_period)
-- calculo diferencial - serie
buffer1 = smaFast - smaSlow
-- clculo da mdia mvel ponderada - serie
buffer2 = wma(buffer1, Signal_period)
buyCondition = conditional(buffer1 > buffer2 and buffer1[1] < buffer2[1] and not
(buffer1 < buffer2 and buffer1[1] > buffer2[1]))
buyCondition = conditional(buffer1 > buffer2 and buffer1[1] < buffer2[1])
sellCondition = conditional(buffer1 < buffer2 and buffer1[1] > buffer2[1] and not
(buffer1 > buffer2 and buffer1[1] < buffer2[1]))
sellCondition = conditional(buffer1 < buffer2 and buffer1[1] > buffer2[1] )
plot_shape(
(buyCondition),
"COMPRA NA PROXIMA",
shape_style.triangleup,
shape_size.huge,
colorBuy,
shape_location.belowbar,
-1,
"CALL PROXIMA VELA",
"green"
)
plot_shape(
(sellCondition),
"VENDE NA PROXIMA",
shape_style.triangledown,
shape_size.huge,
colorSell,
shape_location.abovebar,
-1,
"PUT PROXIMA VELA",
"red"
)
MaFast_period = input(3,"Ma Fast period",input.integer,1,1000,1)
MaFast_average = input(4,"Ma Fast average", input.string_selection,averages.titles)
MaFast_title = input(1,"Ma Fast title", input.string_selection,inputs.titles)
MaSlow_period = input(50,"Ma Slow period",input.integer,1,1000,1)
MaSlow_average = input(4,"Ma Slow average", input.string_selection,averages.titles)
MaSlow_title = input(1,"Ma Slow title", input.string_selection,inputs.titles)
MaTrend_period = input(100,"Ma Trend period",input.integer,1,1000,5)
MaTrend_average = input(2,"Ma Trend average",
input.string_selection,averages.titles)
MaTrend_title = input(1,"Ma Trend title", input.string_selection,inputs.titles)
input_group {
"Ma Fast Line",
colorFast = input { default = "White", type = input.color },
widthFast = input { default = 1, type = input.line_width},
visibleFast = input { default = true, type = input.plot_visibility }
}
input_group {
"Ma Slow Line",
colorSlow = input { default = "purple", type = input.color },
widthSlow = input { default = 2, type = input.line_width},
visibleSlow = input { default = true, type = input.plot_visibility }
}
input_group {
"Buy Outside Bar",
colorBuy2 = input { default = "blue baby", type = input.color },
visibleBuy2 = input { default = false, type = input.plot_visibility }
}
input_group {
"Sell Outside Bar",
colorSell2 = input { default = "pink", type = input.color },
visibleSell2 = input { default = false, type = input.plot_visibility }
}
local avgFast = averages[MaFast_average]
local titleFast = inputs[MaFast_title]
local avgSlow = averages[MaSlow_average]
local titleSlow = inputs[MaSlow_title]
local avgTrend = averages[MaTrend_average]
local titleTrend = inputs[MaTrend_title]
if visibleFast == true then
plot(avgFast(titleFast,MaFast_period),"Ma Fast",colorFast,widthFast)
end
if visibleSlow == true then
plot(avgSlow(titleSlow,MaSlow_period),"Ma Slow",colorSlow,widthSlow)
end
if visibleTrend == true then
plot(avgTrend(titleTrend,MaTrend_period),"Ma Trend",colorTrend,widthTrend)
end
candle_time = {"1s", "5s", "10s", "15s", "30s", "1m", "2m", "5m", "10m", "15m",
"30m", "1H", "2H", "4H", "8H", "12H", "1D", "1W", "1M", "1Y"}
candle_time_res = input(6,"Candle check
resolution",input.string_selection,candle_time)
sec = security (current_ticker_id, candle_time[candle_time_res])
filter_source = {"1s", "5s", "10s", "15s", "30s", "1m", "2m", "5m", "10m", "15m",
"30m", "1H", "2H", "4H", "8H", "12H", "1D", "1W", "1M", "1Y"}
filter_pa_index = input(8,"Candle check
resolution",input.string_selection,filter_source)
filter_pa = security (current_ticker_id, filter_source[filter_pa_index])
MaFast_period = input(3,"Ma Fast period",input.integer,1,1000,1)
MaFast_average = input(4,"Ma Fast average", input.string_selection,averages.titles)
MaFast_title = input(1,"Ma Fast title", input.string_selection,inputs.titles)
MaSlow_period = input(50,"Ma Slow period",input.integer,1,1000,1)
MaSlow_average = input(4,"Ma Slow average", input.string_selection,averages.titles)
MaSlow_title = input(1,"Ma Slow title", input.string_selection,inputs.titles)
MaTrend_period = input(200,"Ma Trend period",input.integer,1,1000,5)
MaTrend_average = input(2,"Ma Trend average",
input.string_selection,averages.titles)
MaTrend_title = input(1,"Ma Trend title", input.string_selection,inputs.titles)
input_group {
"Buy Arrow",
colorBuy = input { default = "green", type = input.color },
visibleBuy = input { default = true, type = input.plot_visibility }
}
input_group {
"Sell Arrow",
colorSell = input { default = "red", type = input.color },
visibleSell = input { default = true, type = input.plot_visibility }
}
local avgFast = averages[MaFast_average]
local titleFast = inputs[MaFast_title]
local avgSlow = averages[MaSlow_average]
local titleSlow = inputs[MaSlow_title]
local avgTrend = averages[MaTrend_average]
local titleTrend = inputs[MaTrend_title]
if visibleFast == true then
plot(avgFast(titleFast,MaFast_period),"Ma Fast",colorFast,widthFast)
end
if visibleSlow == true then
plot(avgSlow(titleSlow,MaSlow_period),"Ma Slow",colorSlow,widthSlow)
end
if visibleTrend == true then
plot(avgTrend(titleTrend,MaTrend_period),"Ma Trend",colorTrend,widthTrend)
end
candle_time = {"1s", "5s", "10s", "15s", "30s", "1m", "2m", "5m", "10m", "15m",
"30m", "1H", "2H", "4H", "8H", "12H", "1D", "1W", "1M", "1Y"}
candle_time_res = input(6,"Candle check
resolution",input.string_selection,candle_time)
sec = security (current_ticker_id, candle_time[candle_time_res])
if (sec ~= nil) and (sec.open_time == open_time) then
Mafast0 = avgFast(titleFast,MaFast_period) --Ma Fast bar 0
Mafast1 = Mafast0[1] --Ma Fast bar 1
MaSlow0 = avgSlow(titleSlow,MaSlow_period) --Ma Slow bar 0
MaSlow1 = MaSlow0[1]
MaTrend0 = avgTrend(titleTrend,MaTrend_period)
Matrend1 = MaTrend0[1]
end