OPEN-SOURCE SCRIPT

BTC Smart Buy/Sell

58
//version=5
indicator("BTC Smart Buy/Sell", overlay=true)

// === INPUTS ===
rsiPeriod = input.int(14, "RSI Period")
macdFast = input.int(12, "MACD Fast")
macdSlow = input.int(26, "MACD Slow")
macdSignal = input.int(9, "MACD Signal")
atrPeriod = input.int(10, "ATR Period")
atrMultiplier = input.float(3.0, "Supertrend Multiplier")
volMultiplier = input.float(1.5, "Volume Spike Multiplier")

// === CALCULATIONS ===
rsi = ta.rsi(close, rsiPeriod)
[macdLine, signalLine, _] = ta.macd(close, macdFast, macdSlow, macdSignal)
macdCrossUp = ta.crossover(macdLine, signalLine)
macdCrossDown = ta.crossunder(macdLine, signalLine)

// Supertrend
[supertrendDir, supertrend] = ta.supertrend(atrMultiplier, atrPeriod)

// Volume spike
avgVol = ta.sma(volume, 20)
volSpike = volume > avgVol * volMultiplier
volDrop = volume < avgVol * 0.7

// === CONDITIONS ===
buyCond = (rsi < 30 ? 1 : 0) + (macdCrossUp ? 1 : 0) + (supertrendDir == 1 ? 1 : 0) + (volSpike ? 1 : 0)
sellCond = (rsi > 70 ? 1 : 0) + (macdCrossDown ? 1 : 0) + (supertrendDir == -1 ? 1 : 0) + (volDrop ? 1 : 0)

buySignal = buyCond >= 3
sellSignal = sellCond >= 3

// === PLOT ===
plotshape(buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.