instrument {
name = 'DAM Trader Script',
short_name = 'DAM Trader',icon = "None", overlay = true}
MaFast_period = input(1,"Ma Fast period",[Link],1,1000,1)
MaValue = input(5,"Ma Value", input.string_selection,[Link])
MaSlow_period = input(34,"Ma Slow period",[Link],1,1000,1)
Signal_period = input(5,"Signal period",[Link],1,1000,1)
input_group {
"Compra",
colorBuy = input { default = "green", type = [Link] },
visibleBuy = input { default = true, type = input.plot_visibility }
}
input_group {
"Venda",
colorSell = input { default = "red", type = [Link] },
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",
shape_style.arrowup,
shape_size.huge,
colorBuy,
shape_location.belowbar,
-1,
"Compra",
"green"
)
plot_shape(
(sellCondition),
"Venta",
shape_style.arrowdown,
shape_size.huge,
colorSell,
shape_location.abovebar,
-1,
"Venta",
"red"
)
MaFast_period = input(3,"Ma Fast period",[Link],1,1000,1)
MaFast_average = input(4,"Ma Fast average", input.string_selection,[Link])
MaFast_title = input(1,"Ma Fast title", input.string_selection,[Link])
MaSlow_period = input(50,"Ma Slow period",[Link],1,1000,1)
MaSlow_average = input(4,"Ma Slow average", input.string_selection,[Link])
MaSlow_title = input(1,"Ma Slow title", input.string_selection,[Link])
MaTrend_period = input(100,"Ma Trend period",[Link],1,1000,5)
MaTrend_average = input(2,"Ma Trend average",
input.string_selection,[Link])
MaTrend_title = input(1,"Ma Trend title", input.string_selection,[Link])
input_group {
"Ma Fast Line",
colorFast = input { default = "", type = [Link] },
widthFast = input { default = 1, type = input.line_width},
visibleFast = input { default = true, type = input.plot_visibility }
}
input_group {
"Ma Slow Line",
colorSlow = input { default = "", type = [Link] },
widthSlow = input { default = 2, type = input.line_width},
visibleSlow = input { default = true, type = input.plot_visibility }
}
input_group {
"Buy Outside Bar",
colorBuy2 = input { default = "", type = [Link] },
visibleBuy2 = input { default = false, type = input.plot_visibility }
}
input_group {
"Sell Outside Bar",
colorSell2 = input { default = "", type = [Link] },
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",[Link],1,1000,1)
MaFast_average = input(4,"Ma Fast average", input.string_selection,[Link])
MaFast_title = input(1,"Ma Fast title", input.string_selection,[Link])
MaSlow_period = input(50,"Ma Slow period",[Link],1,1000,1)
MaSlow_average = input(4,"Ma Slow average", input.string_selection,[Link])
MaSlow_title = input(1,"Ma Slow title", input.string_selection,[Link])
MaTrend_period = input(200,"Ma Trend period",[Link],1,1000,5)
MaTrend_average = input(2,"Ma Trend average",
input.string_selection,[Link])
MaTrend_title = input(1,"Ma Trend title", input.string_selection,[Link])
instrument{name="DAM Trader",
short_name="DAM Trader",
icon = 'None',
overlay=true}
Exibir_tracamento= input(1, "Deseja exibir o tracamento?", input.string_selection,
{"SIM", "NAO"})
smaa= sma(close, '20')
upper_band= smaa + (stdev(close,20) * 3)
lower_band= smaa - (stdev(close,20) * 3)
emaa= ema(close, '100')
if Exibir_tracamento == 1 then
plot(emaa, "SMA", ema_color)
plot(upper_band, "UPPER_BAND", bbsup_color)
plot(lower_band, "LOWER_BAND", bbinf_color)
end
input_group {
"Buy Arrow",
colorBuy = input { default = "green", type = [Link] },
visibleBuy = input { default = true, type = input.plot_visibility }
}
input_group {
"Sell Arrow",
colorSell = input { default = "red", type = [Link] },
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]
instrument{name="DAM Trader Script",icon='None',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=[Link]},width=input{defaul
t=1,type=input.line_width}}h=a()l=e()hline(h,"High",color,high_width)hline(l,"Low",
color,width)hline(highest(10)[1],"HH10",color,1)hline(lowest(10)
[1],"LL10",color,1)hline(highest(30)[1],"HH30",color,1)hline(lowest(30)
[1],"LL30",color,1)hline(highest(60)[1],"HH60",color,1)hline(lowest(60)
[1],"LL60",color,1)hline(highest(100)[1],"HH100",color,1)hline(lowest(100)
[1],"LL100",color,1)hline(highest(150)[1],"HH150",color,1)hline(lowest(150)
[1],"LL150",color,1)hline(highest(200)[1],"HH200",color,1)hline(lowest(200)
[1],"LL200",color,1)
instrument {name = "DAM Trader Script", icon = "None", overlay = true}
bar_look = input (3, "Confirmation bars to look", [Link], 1 )
period1 = input (20, "period Line 1", [Link], 10 )
period2 = input (50, "period Line 2", [Link], 10 )
period3 = input (80, "period Line 3", [Link], 10 )
period4 = input (120, "period Line 4", [Link], 10 )
period5 = input (150, "period Line 5", [Link], 10 )
period6 = input (200, "period Line 6", [Link], 10 )
period7 = input (250, "period Line 7", [Link], 10 )
period8 = input (300, "period Line 8", [Link], 10 )
period9 = input (350, "period Line 9", [Link], 10 )
period10 = input (400, "period Line 10", [Link], 10 )
input_group {
"Color",
color = input {default = "red", type = [Link]},
width = input {default = 1, type = input.line_width}
}
hline(highest(high[bar_look], period1), "HH10", color, width)
hline(lowest(low[bar_look], period1), "LL10", color, width)
hline(highest(high[bar_look], period2), "HH10", color, width)
hline(lowest(low[bar_look], period2), "LL10", color, width)
hline(highest(high[bar_look], period3), "HH10", color, width)
hline(lowest(low[bar_look], period3), "LL10", color, width)
hline(highest(high[bar_look], period4), "HH10", color, width)
hline(lowest(low[bar_look], period4), "LL10", color, width)
hline(highest(high[bar_look], period5), "HH10", color, width)
hline(lowest(low[bar_look], period5), "LL10", color, width)
hline(highest(high[bar_look], period6), "HH10", color, width)
hline(lowest(low[bar_look], period6), "LL10", color, width)
hline(highest(high[bar_look], period7), "HH10", color, width)
hline(lowest(low[bar_look], period7), "LL10", color, width)
hline(highest(high[bar_look], period8), "HH10", color, width)
hline(lowest(low[bar_look], period8), "LL10", color, width)
hline(highest(high[bar_look], period9), "HH10", color, width)
hline(lowest(low[bar_look], period9), "LL10", color, width)
hline(highest(high[bar_look], period10), "HH10", color, width)
hline(lowest(low[bar_look], period10), "LL10", color, width)
end