0% found this document useful (0 votes)
9 views12 pages

SCRIPTS

The document defines the inputs and calculations for a technical analysis indicator script in Pine Script. It includes settings for moving averages, signals, and plotting shapes and lines to visualize buy and sell signals.

Uploaded by

alexbarreto2205
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views12 pages

SCRIPTS

The document defines the inputs and calculations for a technical analysis indicator script in Pine Script. It includes settings for moving averages, signals, and plotting shapes and lines to visualize buy and sell signals.

Uploaded by

alexbarreto2205
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

instrument {

name = 'ALEXBARRETO',
short_name = 'super',
icon = 'indicators:BB',
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 fiu Proxima vela",
colorBuy = input { default = "green", type = input.color },
visibleBuy = input { default = true, type = input.plot_visibility }
}

input_group {
"Venda fiu Proxima vela",
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,
"COMPRA",
"green"
)

plot_shape(
(sellCondition),
"ENTER",
shape_style.triangledown,
shape_size.huge,
colorSell,
shape_location.abovebar,
-1,
"VENDA",
"red"
)

instrument{name="LEON+CHATGPT",icon='https://www.google.com/url?sa=i&url=https%3A
%2F%2Fmyicons.co
%2F&psig=AOvVaw3UTgfDo_l_YxT4qVtiaoE7&ust=1638095965421000&source=images&cd=vfe&ved
=0CAsQjRxqFwoTCKCli5WtuPQCFQAAAAAdAAAAABAD',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="blue",type=input.color},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)

MaFast_period = input(2,"Ma Fast period",input.integer,1,1000,1)


MaFast_average = input(2,"Ma Fast average", input.string_selection,averages.titles)
MaFast_title = input(1,"Ma Fast title", input.string_selection,inputs.titles)

MaSlow_period = input(8,"Ma Slow period",input.integer,1,1000,1)


MaSlow_average = input(2,"Ma Slow average", input.string_selection,averages.titles)
MaSlow_title = input(1,"Ma Slow title", input.string_selection,inputs.titles)

Signal_period = input(6,"Signal period",input.integer,1,1000,1)

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 {
"Area Up and Down",
colorAreaUp = input { default = "rgba(34, 139, 34, 0.3)", type = input.color },
colorAreaDown = input { default = "rgba(220, 20, 60, 0.3)", type =
input.color },
visibleArea = input { default = true, type = input.plot_visibility }
}

input_group {
"Ma Fast Line",
colorFast = input { default = "#ff56e8", type = input.color },
widthFast = input { default = 1, type = input.line_width},
visibleFast = input { default = false, type = input.plot_visibility }
}

input_group {
"Ma Slow Line",
colorSlow = input { default = "#2d2af7", type = input.color },
widthSlow = input { default = 2, type = input.line_width},
visibleSlow = input { default = false, type = input.plot_visibility }
}

input_group {
"Ma Trend Line",
colorTrend = input { default = "#f74200", type = input.color },
widthTrend = input { default = 3, type = input.line_width},
visibleTrend = input { default = false, type = input.plot_visibility }
}

input_group {
"Buy Engulfing",
colorBuy = input { default = "green", type = input.color },
visibleBuy = input { default = false, type = input.plot_visibility }
}

input_group {
"Sell Engulfing",
colorSell = input { default = "red", type = input.color },
visibleSell = input { default = false, type = input.plot_visibility }
}

input_group {
"Buy Double Engulfing",
colorBuy1 = input { default = "rgba(34, 139, 34, 0.8)", type = input.color },
visibleBuy1 = input { default = false, type = input.plot_visibility }
}

input_group {
"Sell Double Engulfing",
colorSell1 = input { default = "rgba(220, 20, 60, 0.8)", type = input.color },
visibleSell1 = input { default = false, type = input.plot_visibility }
}

input_group {
"Buy Outside Bar",
colorBuy2 = input { default = "rgba(0, 0, 255, 0.8)", type = input.color },
visibleBuy2 = input { default = false, type = input.plot_visibility }
}

input_group {
"Sell Outside Bar",
colorSell2 = input { default = "rgba(255, 20, 147, 0.8)", type = input.color },
visibleSell2 = input { default = false, type = input.plot_visibility }
}

input_group {
"Buy X Macd",
colorBuy3 = input { default = "rgba(0, 0, 255, 0.8)", type = input.color },
visibleBuy3 = input { default = false, type = input.plot_visibility }
}

input_group {
"Sell X Macd",
colorSell3 = input { default = "rgba(255, 20, 147, 0.8)", type = input.color },
visibleSell3 = input { default = false, type = input.plot_visibility }
}

input_group {
"Buy X Zero",
colorBuy4 = input { default = "rgba(0, 250, 154, 0.80)", type = input.color },
visibleBuy4 = input { default = false, type = input.plot_visibility }
}

input_group {
"Sell X Zero",
colorSell4 = input { default = "rgba(255, 20, 147, 0.60)", type =
input.color },
visibleSell4 = input { default = false, type = input.plot_visibility }
}

input_group {
"Buy Histo X",
colorBuy5 = input { default = "rgba(0, 250, 154, 0.80)", type = input.color },
visibleBuy5 = input { default = true, type = input.plot_visibility }
}

input_group {
"Sell Histo X",
colorSell5 = input { default = "rgba(255, 20, 147, 0.60)", type =
input.color },
visibleSell5 = 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 avgSignal = averages[Signal_period]

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 = {"1m", "2m", "5m", "10m", "15m", "30m", "1H", "2H", "4H"}
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 = {"1m", "2m", "5m", "10m", "15m", "30m", "1H", "2H", "4H"}
filter_pa_index = input(8,"Candle check
resolution",input.string_selection,filter_source)

filter_pa = security (current_ticker_id, filter_source[filter_pa_index])

--print(filter_source[filter_pa_index])

emaFast = avgFast(titleFast,MaFast_period)
emaSlow = avgSlow(titleSlow,MaSlow_period)
macd = emaFast - emaSlow

signal = avgSignal(macd,Signal_period)

--plot(macd,"macd", "Blue", 1)
--plot(signal,"signal", "Orange", 1)

histo = macd - signal

--rect {
--first = 0,
--second = histo,
--color = histo >= histo[1] and "LimeGreen" or "Orange",
--width = 0.5
--}

--hline(0,"Zero Macd", "rgba(255, 20, 147, 0.4)",1)

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]

if(visibleBuy == true) then


plot_shape((close > open and close[1] < open[1] and close > MaFast0 and
MaFast0 > MaSlow0 and MaSlow0 > MaTrend0 and close > open[1] and open <= close[1]
and abs(close-open) > abs(close[1]-open[1])),
"Call",
shape_style.arrowup,
shape_size.huge,
colorBuy,
shape_location.belowbar,
0

)
end

if (visibleSell == true) then


plot_shape((close < open and close[1] > open[1] and close < MaFast0 and
MaFast0 < MaSlow0 and MaSlow0 < MaTrend0 and close < open[1] and open >= close[1]
and abs(close-open) > abs(close[1]-open[1])),
"Put",
shape_style.arrowdown,
shape_size.huge,
colorSell,
shape_location.abovebar,
0

)
end

if(visibleBuy1 == true) then


if(filter_pa.close[1] > filter_pa.open[1] and filter_pa.close[2] <
filter_pa.open[2] and filter_pa.close[1] > filter_pa.open[2] and filter_pa.open[1]
<= filter_pa.close[2] and abs(filter_pa.close[1]-filter_pa.open[1]) >
abs(filter_pa.close[2]-filter_pa.open[2]) ) then
plot_shape((close > open and close[1] < open[1] and close > open[1] and
open <= close[1] and abs(close-open) > abs(close[1]-open[1])),
"Call1",
shape_style.arrowup,
shape_size.huge,
colorBuy1,
shape_location.belowbar,
0

)
end
end

if (visibleSell1 == true) then


if(filter_pa.close[1] < filter_pa.open[1] and filter_pa.close[2] >
filter_pa.open[2] and filter_pa.close[1] < filter_pa.open[2] and filter_pa.open[1]
>= filter_pa.close[2] and abs(filter_pa.close[1]-filter_pa.open[1]) >
abs(filter_pa.close[2]-filter_pa.open[2]) ) then
plot_shape((close < open and close[1] > open[1] and close < open[1] and
open >= close[1] and abs(close-open) > abs(close[1]-open[1])),
"Put1",
shape_style.arrowdown,
shape_size.huge,
colorSell1,
shape_location.abovebar,
0

)
end
end

if(visibleBuy2 == true) then


--if(filter_pa.close[1] > filter_pa.open[1] and filter_pa.close[2] <
filter_pa.open[2] and filter_pa.close[1] > filter_pa.open[2] and filter_pa.open[1]
<= filter_pa.close[2] and abs(filter_pa.close[1]-filter_pa.open[1]) >
abs(filter_pa.close[2]-filter_pa.open[2]) ) then
plot_shape((open[3] < close[3] and open[2] < close[2] and open[1] >
close[1] and close[1] > open[2] and open[1] > open[2] and open < close),
"Call2",
shape_style.arrowup,
shape_size.huge,
colorBuy2,
shape_location.belowbar,
0
)
--end
end

if (visibleSell2 == true) then


--if(filter_pa.close[1] < filter_pa.open[1] and filter_pa.close[2] >
filter_pa.open[2] and filter_pa.close[1] < filter_pa.open[2] and filter_pa.open[1]
>= filter_pa.close[2] and abs(filter_pa.close[1]-filter_pa.open[1]) >
abs(filter_pa.close[2]-filter_pa.open[2]) ) then
plot_shape((open[3] > close[3] and open[2] > close[2] and open[1] <
close[1] and close[1] < open[2] and open[1] < open[2] and open > close),
"Put2",
shape_style.arrowdown,
shape_size.huge,
colorSell2,
shape_location.abovebar,
0

)
--end
end

if(visibleBuy3 == true) then


--if(filter_pa.close[1] > filter_pa.open[1] and filter_pa.close[2] <
filter_pa.open[2] and filter_pa.close[1] > filter_pa.open[2] and filter_pa.open[1]
<= filter_pa.close[2] and abs(filter_pa.close[1]-filter_pa.open[1]) >
abs(filter_pa.close[2]-filter_pa.open[2]) ) then
plot_shape((macd > signal and macd[1] < signal[1] and close > MaFast0
and MaFast0 > MaTrend0),
"Call3",
shape_style.arrowup,
shape_size.huge,
colorBuy3,
shape_location.belowbar,
0

)
--end
end

if (visibleSell3 == true) then


--if(filter_pa.close[1] < filter_pa.open[1] and filter_pa.close[2] >
filter_pa.open[2] and filter_pa.close[1] < filter_pa.open[2] and filter_pa.open[1]
>= filter_pa.close[2] and abs(filter_pa.close[1]-filter_pa.open[1]) >
abs(filter_pa.close[2]-filter_pa.open[2]) ) then
plot_shape((macd < signal and macd[1] > signal[1] and close < MaFast0 and
MaFast0 < MaTrend0),
"Put3",
shape_style.arrowdown,
shape_size.huge,
colorSell3,
shape_location.abovebar,
0

)
--end
end

if(visibleBuy4 == true) then


--if(filter_pa.close[1] > filter_pa.open[1] and filter_pa.close[2] <
filter_pa.open[2] and filter_pa.close[1] > filter_pa.open[2] and filter_pa.open[1]
<= filter_pa.close[2] and abs(filter_pa.close[1]-filter_pa.open[1]) >
abs(filter_pa.close[2]-filter_pa.open[2]) ) then
plot_shape((macd[1] < 0 and macd > 0 ),
"Call4",
shape_style.arrowup,
shape_size.huge,
colorBuy4,
shape_location.belowbar,
0

)
--end
end

if (visibleSell4 == true) then


--if(filter_pa.close[1] < filter_pa.open[1] and filter_pa.close[2] >
filter_pa.open[2] and filter_pa.close[1] < filter_pa.open[2] and filter_pa.open[1]
>= filter_pa.close[2] and abs(filter_pa.close[1]-filter_pa.open[1]) >
abs(filter_pa.close[2]-filter_pa.open[2]) ) then
plot_shape((macd[1] > 0 and macd < 0 ),
"Put4",
shape_style.arrowdown,
shape_size.huge,
colorSell4,
shape_location.abovebar,
0

)
--end
end

if(visibleBuy5 == true) then


--if(filter_pa.close[1] > filter_pa.open[1] and filter_pa.close[2] <
filter_pa.open[2] and filter_pa.close[1] > filter_pa.open[2] and filter_pa.open[1]
<= filter_pa.close[2] and abs(filter_pa.close[1]-filter_pa.open[1]) >
abs(filter_pa.close[2]-filter_pa.open[2]) ) then
plot_shape((histo[1] < 0 and histo > 0 ),
"Call5",
shape_style.arrowup,
shape_size.huge,
colorBuy5,
shape_location.belowbar,
0

)
--end
end

if (visibleSell5 == true) then


--if(filter_pa.close[1] < filter_pa.open[1] and filter_pa.close[2] >
filter_pa.open[2] and filter_pa.close[1] < filter_pa.open[2] and filter_pa.open[1]
>= filter_pa.close[2] and abs(filter_pa.close[1]-filter_pa.open[1]) >
abs(filter_pa.close[2]-filter_pa.open[2]) ) then
plot_shape((histo[1] > 0 and histo < 0 ),
"Put5",
shape_style.arrowdown,
shape_size.huge,
colorSell5,
shape_location.abovebar,
0

)
--end
end

if (visibleArea == true) then


fill(MaFast0,MaSlow0,"Area", MaFast0 > MaSlow0 and colorAreaUp or MaFast0 <
MaSlow0 and colorAreaDown )

end

Linhas H4
instrument { name = "LINHA DE H4", icon="indicators:ADX", overlay = true }
method_id = input (1, "Type", input.string_selection, { "JOSE TRADE" })

input_group {
"Maxima",
level_1_color = input { default = " White", ", type = input.color },
level_1_width = input { default = 4, type = input.line_width }
}

input_group {
"Minima",
level_2_color = input { default = "White", type = input.color },
level_2_width = input { default = 4, type = input.line_width }
}

local function h4(candle)

c1 = candle.high
c2 = candle.low
end

local methods = { h4 }

local resolution = "4H"

sec = security (current_ticker_id, resolution)

if sec then
local method = methods [method_id]
method (sec)

plot (c1, "C1", level_1_color, level_1_width, 0, style.levels, na_mode.continue)


plot (c2, "C2", level_2_color, level_2_width, 0, style.levels, na_mode.continue)

end
instrument { name = "REVERSAO TENDENCIA",
icon="https://qualificacaodigital.com/wp-content/uploads/2022/01/JOSE-TRADER-opcoes-binarias-forex-
iq-binance-day-trader.jpg", overlay = true }

input_group {
"Compra",
comprar_color = input {default = "green", type = input.color}
}

input_group {
"Periodo Max/Min",
doch_time = input {default = "30", type = input.string}
}

input_group {
"Periodo da Micro Tendencia",
emaa_per = input {default = "21", type = input.string}
}

input_group {
"Periodo da Macro Tendencia",
emab_per = input {default = "200", type = input.string}
}

input_group {
"Media Rapida",
emac_per = input {default = "7", type = input.string}
}

input_group {
"Media Lenta",
emad_per = input {default = "17", type = input.string}
}

input_group {
"Venda",
vender_color = input {default = "red", type = input.color}
}

input_group {
"Resistencia",
upline_color = input {default = "red", type = input.color}
}

input_group {
"Suporte",
lowline_color = input {default = "green", type = input.color}
}

input_group {
"Candles",
positivo = input { default = "green",type = input.color },
neutro = input { default = "gray", type = input.color },
negativo = input { default = "red", type = input.color },
}
--PARAMETROS

EMAA = ema(close,emaa_per)
EMAB = ema(close,emab_per)
EMAC = ema(hlc3,emac_per)
EMAD = ema(hlc3,emad_per)
upper = highest (high, doch_time)
lower = lowest (low, doch_time)

--CALCULOS

TA = ((close > close[1]) and (close > EMAA) and (EMAA > EMAA[1]))
TB = ((close < close[1]) and (close < EMAA) and (EMAA < EMAA[1]))
ENC = ((EMAC[1] < EMAD[1]) and (EMAC > EMAD))
ENV = ((EMAC[1] > EMAD[1]) and (EMAC < EMAD))

sec = security (current_ticker_id, "1m")


if sec then

local bar_color

if (TA == true) then


bar_color = positivo
elseif (TB == true) then
bar_color = negativo
else
bar_color = neutro
end

plot_candle (open, high, low, close, "ES", bar_color)


plot (upper, "Resistencia", upline_color)
plot (lower, "Suporte",lowline_color)

--NEGOCIAO

plot_shape((ENV),
"VENDER",
shape_style.flag,
shape_size.huge,
vender_color,
shape_location.abovebar,
0,
"BAIXA",
vender_color)

plot_shape((ENC),
"COMPRAR",
shape_style.flag,
shape_size.huge,
comprar_color,
shape_location.belowbar,
0,
"ALTA",
comprar_color)

end

You might also like