- by Tsabithah Salsabilla Oklid
- Jul 22, 2024
Analisa trading dengan menggunakan TradingView dapat membantu trader dalam mengambil keputusan beli dan jual dengan lebih percaya diri. Pada artikel ini, kita akan membahas sebuah skrip indikator yang menggabungkan berbagai alat analisis teknikal seperti MACD, RSI, Bollinger Bands, serta support dan resistance. Skrip ini dapat digunakan untuk semua trading pair, memberikan sinyal beli/jual beserta level take profit.
Berikut adalah kode lengkap untuk indikator TradingView:
pinescript Salin kode //@version=5 indicator("Buy/Sell with TP, Support and Resistance", shorttitle="BS SR", overlay=true) // Input parameters fastLength = input(12, title="MACD Fast Length") slowLength = input(26, title="MACD Slow Length") signalSmoothing = input(9, title="MACD Signal Smoothing") tpPerc = input.float(2, title="Take Profit (%)") pivotLen = input.int(5, title="Pivot Length") // Calculate MACD [macdLine, signalLine, _] = ta.macd(close, fastLength, slowLength, signalSmoothing) // Calculate RSI rsiLength = input(14, title="RSI Length") rsi = ta.rsi(close, rsiLength) // Calculate Bollinger Bands bbLength = input(20, title="BB Length") bbMultiplier = input.float(2.0, title="BB Multiplier") basis = ta.sma(close, bbLength) dev = ta.stdev(close, bbLength) upperBand = basis + dev * bbMultiplier lowerBand = basis - dev * bbMultiplier // Buy signal: MACD line crosses above the signal line and RSI below 30 (oversold) buySignal = ta.crossover(macdLine, signalLine) and rsi < 30 // Sell signal: MACD line crosses below the signal line and RSI above 70 (overbought) sellSignal = ta.crossunder(macdLine, signalLine) and rsi > 70 // Take profit level var float entryPrice = na var float tpLevel = na if (buySignal) entryPrice := close tpLevel := entryPrice * (1 + tpPerc / 100) if (sellSignal) entryPrice := na tpLevel := na // Plot signals on the chart plotshape(series=buySignal, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY") plotshape(series=sellSignal, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL") // Plot take profit level plot(tpLevel, style=plot.style_line, color=color.white, linewidth=2, title="Take Profit") // Close conditions var bool closeBuy = na var bool closeSell = na if (buySignal) closeBuy := ta.crossunder(macdLine, signalLine) // Close buy when MACD crosses below signal if (sellSignal) closeSell := ta.crossover(macdLine, signalLine) // Close sell when MACD crosses above signal // Plot close signals plotshape(series=closeBuy, location=location.abovebar, color=color.red, style=shape.labeldown, text="Close Buy") plotshape(series=closeSell, location=location.belowbar, color=color.green, style=shape.labelup, text="Close Sell") // Plot Bollinger Bands plot(upperBand, color=color.blue, title="Upper BB") plot(lowerBand, color=color.blue, title="Lower BB") // Plot RSI plot(rsi, title="RSI", color=color.orange) // Support and Resistance detection using pivots pivotHigh = ta.pivothigh(high, pivotLen, pivotLen) pivotLow = ta.pivotlow(low, pivotLen, pivotLen) // Plot Support and Resistance levels plot(pivotHigh, style=plot.style_circles, color=color.yellow, linewidth=2, title="Resistance") plot(pivotLow, style=plot.style_circles, color=color.blue, linewidth=2, title="Support") // Alert conditions alertcondition(buySignal, title="Buy Alert", message="Buy Signal") alertcondition(sellSignal, title="Sell Alert", message="Sell Signal")
Skrip ini memberikan alat yang komprehensif untuk analisis teknikal berbagai trading pair. Dengan menggabungkan beberapa indikator dan level support/resistance, trader dapat membuat keputusan trading yang lebih baik. Pastikan untuk selalu menguji dan mengkustomisasi skrip ini sesuai dengan strategi trading Anda.