OPEN-SOURCE SCRIPT

Fibonacci EMA RSI MACD Strategy

88
//version=5
indicator("Fibonacci EMA RSI MACD Strategy", overlay=true)

// 🟢 Tham số đầu vào
emaShortLength = input(20, title="EMA Ngắn")
emaMediumLength = input(50, title="EMA Trung bình")
emaLongLength = input(100, title="EMA Dài")
emaVeryLongLength = input(200, title="EMA Rất dài")

rsiLength = input(14, title="RSI Length")
macdFastLength = input(12, title="MACD Fast")
macdSlowLength = input(26, title="MACD Slow")
macdSignalLength = input(9, title="MACD Signal")

fiboLookback = input(50, title="Fibonacci Lookback Bars")

// 🔵 Tính toán EMA
emaShort = ta.ema(close, emaShortLength)
emaMedium = ta.ema(close, emaMediumLength)
emaLong = ta.ema(close, emaLongLength)
emaVeryLong = ta.ema(close, emaVeryLongLength)

// 🔴 Tính toán MACD
[macdLine, signalLine, _] = ta.macd(close, macdFastLength, macdSlowLength, macdSignalLength)
macdCrossUp = ta.crossover(macdLine, signalLine)
macdCrossDown = ta.crossunder(macdLine, signalLine)

// 🟣 Tính toán RSI
rsi = ta.rsi(close, rsiLength)
rsiOverSold = rsi < 30
rsiOverBought = rsi > 70

// 🟠 Xác định xu hướng EMA
uptrend = emaShort > emaMedium and emaMedium > emaLong and emaLong > emaVeryLong
downtrend = emaShort < emaMedium and emaMedium < emaLong and emaLong < emaVeryLong

// 🟢 Xác định Fibonacci Retracement
fiboHigh = ta.highest(high, fiboLookback)
fiboLow = ta.lowest(low, fiboLookback)
fibo_0_618 = fiboHigh - (fiboHigh - fiboLow) * 0.618
fibo_0_382 = fiboHigh - (fiboHigh - fiboLow) * 0.382
fibo_0_236 = fiboHigh - (fiboHigh - fiboLow) * 0.236

// 🟢 Tín hiệu MUA khi giá ở vùng Fibonacci và có động lượng mạnh
buySignal = uptrend and macdCrossUp and rsiOverSold and close > fibo_0_618
sellSignal = downtrend and macdCrossDown and rsiOverBought and close < fibo_0_382

// 🎯 Hiển thị đường EMA
plot(emaShort, color=color.blue, title="EMA 20")
plot(emaMedium, color=color.orange, title="EMA 50")
plot(emaLong, color=color.green, title="EMA 100")
plot(emaVeryLong, color=color.red, title="EMA 200")

// 🎯 Hiển thị Fibonacci Retracement Levels
plot(fibo_0_618, color=color.gray, title="Fibo 61.8%")
plot(fibo_0_382, color=color.gray, title="Fibo 38.2%")
plot(fibo_0_236, color=color.gray, title="Fibo 23.6%")

// 🎯 Hiển thị tín hiệu mua/bán
plotshape(series=buySignal, location=location.belowbar, color=color.green, style=shape.labelup, title="BUY", text="Mua")
plotshape(series=sellSignal, location=location.abovebar, color=color.red, style=shape.labeldown, title="SELL", text="Bán")

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.