Projeto Médias Minutos

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Projeto Médias minutos

//@version=5

strategy("Keltner Channels Strategy", overlay=true)

length = input(34, title="Length")


lenght2 = input(9, title="Lenght2")
mult = input(2, title="Multiplier")
mult2 = input(3, title="Multplier2")

basis = ta.sma(close, length)


basis2 = ta.sma(close,lenght2)
atr = ta.atr(length)

upper_band = basis + (mult * atr)


upper_band2 = basis + (mult2 * atr)
lower_band = basis - (mult * atr)
lower_band2 = basis - (mult2 * atr)

plot(basis, color=color.blue, title="Basis")


plot(basis2, color=color.white, title="Basis2")

enterLong = ta.crossover(close, basis2)

enterShort = ta.crossunder(close, basis2)

LongCondition = ta.crossover (basis2, basis)


if (LongCondition)
strategy.entry("Long", strategy.long)

ShortCondition = ta.crossunder (basis2, basis)


if (ShortCondition)
strategy.entry("Short", strategy.short)

AtivaTSLong = strategy.position_avg_price * 1.001


AtivaTSShort = strategy.position_avg_price *0.997
strategy.exit("Exit Long", "Long", trail_price = AtivaTSLong, trail_offset = 1 )
strategy.exit("Exit Short", "Short", trail_price = AtivaTSShort, trail_offset = 1 )

You might also like