0% found this document useful (0 votes)
101 views2 pages

TINCHO

The document defines inputs for a trading strategy that uses moving averages (MA) and the moving average convergence divergence (MACD) indicator. It takes user inputs for the fast and slow MA periods to calculate the MACD, as well as the signal period. It then calculates the fast and slow MAs, MACD, signal line, and histogram. It also takes a period for an exponential moving average (EMA) and colors bars based on the EMA and histogram values to indicate buy/sell signals.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views2 pages

TINCHO

The document defines inputs for a trading strategy that uses moving averages (MA) and the moving average convergence divergence (MACD) indicator. It takes user inputs for the fast and slow MA periods to calculate the MACD, as well as the signal period. It then calculates the fast and slow MAs, MACD, signal line, and histogram. It also takes a period for an exponential moving average (EMA) and colors bars based on the EMA and histogram values to indicate buy/sell signals.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

instrument {

name = 'TINCHO',
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(9,"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.cross,
shape_size.huge,
colorBuy,
shape_location.belowbar,
-1,
"",
"green"
)
plot_shape(
(sellCondition),
"",
shape_style.cross,
shape_size.huge,
colorSell,
shape_location.abovebar,
-1,
"",
"red"
)
instrument {
name = "TINCHO TRADER",
icon = "https://cdn.pixabay.com/photo/2019/02/19/19/45/thumbs-up-
4007573_960_720.png",
overlay = " true",
}
input_group {
"MACD",
"Slow and fast EMA periods, used in MACD calculation",
fast = input (12, "front.platform.fast period", input.integer, 1, 250),
slow = input (26, "front.platform.fast period", input.integer, 1, 250)
}
input_group {
"front.platform.signal-line",
"Reference signal series period",
signal_period = input (9, "front.period", input.integer, 1, 250)
}
input_group {
"front.newind.emaperiod",
ema_period = input (9, "front.period", input.integer, 1, 250)
}
input_group {
"front.newind.barcolors",
positive = input { default = "#2CAC40", type = input.color },
neutral = input { default = "#C7CAD1", type = input.color },
negative = input { default = "#DB4931", type = input.color },
}
fastMA = ema(close, fast)
slowMA = ema(close, slow)
macd = fastMA - slowMA
signal = sma(macd, signal_period)
hist = macd - signal
ema13 = ema (close, ema_period)
local bar_color
if ema13 > ema13 [1] and hist > hist [1] then
bar_color = positive
elseif ema13 < ema13 [1] and hist < hist [1] then
bar_color = negative
else
bar_color = neutral
end
plot_candle (open, high, low, close, "ES", bar_color)

You might also like