instrument{name="PEDRO$"}
instrument {
name = "WIN13",
short_name = 'super',
icon = 'indicators:BB',
overlay = true
}
MaFast_period = input(4,"Ma Fast period",input.integer,1,1000,1)
MaValue = input(2,"Ma Value", input.string_selection,inputs.titles)
MaSlow_period = input(38,"Ma Slow period",input.integer,1,1000,1)
Signal_period = input(2,"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),
"",
shape_style.triangleup,
shape_size.huge,
colorBuy,
shape_location.belowbar,
-1,
"@Pedro",
"green"
)
plot_shape(
(sellCondition),
"",
shape_style.triangledown,
shape_size.huge,
colorSell,
shape_location.abovebar,
-1,
"@Pedro",
"red"
)
instrument {name ="PEDRO", short_name ="PEDRO", overlay=true}
exibir_tracamento = input ( 1, "Desea exibir?", input.string_selection,
{"SI","No"})
input_group { "SMAA", smaa_color = input{ default = "blue", type = input.color }}
input_group { "SMAB", smab_color = input{ default = "blue", type = input.color }}
sec = security(current_ticker_id, "1m")
smaa = sma(close, '3')
smab = sma(close, '50')
smaao = sma(open, '3')
smabo = sma(open, '50')
plot(smaa, "SMA", smaa_color)
plot(smab, "SMA", smab_color)
emaa = ema(close, '100')
period = input (5, "front.period", input.integer, 1)
source = input (7, "front.ind.source", input.string_selection, inputs.titles)
fn = input (9, "front.newind.average", input.string_selection, averages.titles)
input_group {
"front.newind.barcolors",
up_color = input { default = "#2CAC40", type = input.color },
down_color = input { default = "#DB4931", type = input.color }
}
local sourceSeries = inputs [source]
local averageFunction = averages [fn]
mean = averageFunction (sourceSeries, period)
mad = sourceSeries - mean
rect {
first = 0,
second = mad,
color = mad >= mad [1] and up_color or down_color,
width = 0.4
}