OPEN-SOURCE SCRIPT

GENESIS

34
//version=5
indicator("SMAs + Confirmação 2ª Vela + ALERTA", overlay=true)

// Médias
len1 = input.int(8, title="SMA Rápida")
len2 = input.int(21, title="SMA Lenta")

sma1 = ta.sma(close, len1)
sma2 = ta.sma(close, len2)

// Plot
plot(sma1, color=color.green, linewidth=2)
plot(sma2, color=color.blue, linewidth=2)

// Cruzamentos
crossUp = ta.crossover(sma1, sma2)
crossDown = ta.crossunder(sma1, sma2)

// Contadores
var int countUp = 0
var int countDown = 0

if (crossUp)
countUp := 1
else if (countUp > 0)
countUp += 1

if (crossDown)
countDown := 1
else if (countDown > 0)
countDown += 1

// Reset
if (crossDown)
countUp := 0

if (crossUp)
countDown := 0

// Sinais na 2ª vela
buySignal = countUp == 2
sellSignal = countDown == 2

// Plot sinais
plotshape(buySignal, title="COMPRA", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sellSignal, title="VENDA", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

// ALERTAS 🚨
alertcondition(buySignal, title="ALERTA COMPRA", message="📈 COMPRA confirmada após 2ª vela!")
alertcondition(sellSignal, title="ALERTA VENDA", message="📉 VENDA confirmada após 2ª vela!")

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.