PROTECTED SOURCE SCRIPT

WMTrades SMT + PSP

55
//version=5
indicator("WM SMT + PSP PRO", overlay=true, max_lines_count=500)

// ===== INPUTS =====
symbol1 = input.symbol("NQ1!", "Ativo 1")
symbol2 = input.symbol("ES1!", "Ativo 2")
symbol3 = input.symbol("YM1!", "Ativo 3")

useCustomTF = input.bool(false, "Usar timeframe personalizado?")
customTF = input.timeframe("60", "Timeframe personalizado")

useClosedBar = input.bool(true, "Apenas barra fechada?")
barsBack = input.int(100, "Plotar divergências das últimas X barras", minval=1)

// ===== TIMEFRAME =====
tf = useCustomTF ? customTF : timeframe.period

// ===== DADOS SMT =====
h1 = request.security(symbol1, tf, high)
l1 = request.security(symbol1, tf, low)

h2 = request.security(symbol2, tf, high)
l2 = request.security(symbol2, tf, low)

h3 = request.security(symbol3, tf, high)
l3 = request.security(symbol3, tf, low)

// ===== DADOS PSP =====
o1 = request.security(symbol1, tf, open)
c1 = request.security(symbol1, tf, close)

o2 = request.security(symbol2, tf, open)
c2 = request.security(symbol2, tf, close)

o3 = request.security(symbol3, tf, open)
c3 = request.security(symbol3, tf, close)

// ================= SMT =================
rh1 = h1[1]
rl1 = l1[1]
rh2 = h2[1]
rl2 = l2[1]
rh3 = h3[1]
rl3 = l3[1]

bH1 = h1 > rh1
bH2 = h2 > rh2
bH3 = h3 > rh3

bL1 = l1 < rl1
bL2 = l2 < rl2
bL3 = l3 < rl3

bearishSMT = (bH1 or bH2 or bH3) and not (bH1 and bH2 and bH3)
bullishSMT = (bL1 or bL2 or bL3) and not (bL1 and bL2 and bL3)

finalBearSMT = useClosedBar ? bearishSMT and barstate.isconfirmed : bearishSMT
finalBullSMT = useClosedBar ? bullishSMT and barstate.isconfirmed : bullishSMT

// ================= PSP =================
bull1 = c1 > o1
bull2 = c2 > o2
bull3 = c3 > o3

bear1 = c1 < o1
bear2 = c2 < o2
bear3 = c3 < o3

psp = (bull1 or bull2 or bull3) and (bear1 or bear2 or bear3)
finalPSP = useClosedBar ? psp and barstate.isconfirmed : psp

// ===== CONTROLE HISTÓRICO =====
plotAllowed = bar_index >= (bar_index - barsBack)

// ===== SMT DESENHO =====
darkBlue = color.rgb(0, 0, 139)

if finalBearSMT and plotAllowed
line.new(bar_index[1], high[1], bar_index, high, color=darkBlue, width=1)

if finalBullSMT and plotAllowed
line.new(bar_index[1], low[1], bar_index, low, color=darkBlue, width=1)

// ===== PSP DESENHO =====
plotshape(finalPSP, style=shape.circle, location=location.abovebar, color=color.rgb(70,70,70), size=size.tiny)

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.