Untitled

 avatar
unknown
plain_text
a year ago
916 B
24
Indexable
//@version=5
indicator("Futures Triad PSP indicator", overlay=true)

// Input for symbols
sym1 = input.symbol("CME_MINI:ES1!", "Symbol 1")
sym2 = input.symbol("CME_MINI:NQ1!", "Symbol 2")
sym3 = input.symbol("CBOT:YM1!", "Symbol 3")

// Function to get trend: 1 for bullish, -1 for bearish, 0 for neutral
get_trend(symbol) =>
    trend_ = request.security(symbol, timeframe.period, close != open ? (close >= open ? 1 : -1) : 0, gaps = barmerge.gaps_on)
    trend = na(trend_) ? na : trend_
    trend

// Get trends for each symbol
trend1 = get_trend(sym1)
trend2 = get_trend(sym2)
trend3 = get_trend(sym3)

max_sum = math.abs(trend1) + math.abs(trend2) + math.abs(trend3)

// if there is any divergence between candles, consider PSP
divergence = math.abs(trend1 + trend2 + trend3) == max_sum ? 0 : 1

plotshape(series=divergence, title="Divergence", location=location.belowbar, color=color.red, style=shape.circle)

Editor is loading...
Leave a Comment