OPEN-SOURCE SCRIPT

Advanced Bitcoin Trading Strategy

//version=6
indicator("Advanced Bitcoin Trading Strategy", overlay=true)

// Define Short-term and Long-term MAs
shortTermMA = ta.sma(close, 9)
longTermMA = ta.sma(close, 21)

// Define RSI
rsi = ta.rsi(close, 14)

// Define Volume
volumeMA = ta.sma(volume, 20)

// Define Buy and Sell Conditions based on MA Crossovers, RSI, and Volume
buyCondition = ta.crossover(shortTermMA, longTermMA) and rsi < 30 and volume > volumeMA
sellCondition = ta.crossunder(shortTermMA, longTermMA) and rsi > 70 and volume > volumeMA

// Detect Bullish Engulfing Pattern
bullishEngulfing = (open[1] > close[1]) and (close > open) and (close > high[1]) and (open < low[1])

// Detect Bearish Engulfing Pattern
bearishEngulfing = (open[1] < close[1]) and (close < open) and (close < low[1]) and (open > high[1])

// Combine all Buy and Sell Conditions
finalBuyCondition = buyCondition or bullishEngulfing
finalSellCondition = sellCondition or bearishEngulfing

// Plot Short-term and Long-term MA
plot(shortTermMA, "Short Term MA", color=color.blue, linewidth=2)
plot(longTermMA, "Long Term MA", color=color.red, linewidth=2)

// Plot RSI
hline(70, "Overbought Level", color=color.red, linestyle=hline.style_dotted)
hline(30, "Oversold Level", color=color.green, linestyle=hline.style_dotted)
plot(rsi, "RSI", color=color.purple, linewidth=2)

// Plot Volume MA
plot(volumeMA, "Volume MA", color=color.orange, linewidth=1)

// Plot Buy and Sell Arrows
plotshape(series=finalBuyCondition, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=finalSellCondition, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
plotarrow(series=finalBuyCondition ? 1 : na, title="Buy Arrow", colorup=color.green, offset=-1)
plotarrow(series=finalSellCondition ? -1 : na, title="Sell Arrow", colordown=color.red, offset=-1)

// Alert Conditions
alertcondition(finalBuyCondition, title="Buy Alert", message="Time to Buy Bitcoin!")
alertcondition(finalSellCondition, title="Sell Alert", message="Time to Sell Bitcoin!")

คำจำกัดสิทธิ์ความรับผิดชอบ