OPEN-SOURCE SCRIPT

YJ Trading Indicator - Advanced Patterns & Signals

154
//version=5
indicator("YJ Trading Indicator - Advanced Patterns & Signals", overlay=true)

// Moving Averages for trend confirmation
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
trendUp = ema50 > ema200
trendDown = ema50 < ema200

// Fibonacci Levels Calculation
pivotHigh = ta.highest(high, 50)
pivotLow = ta.lowest(low, 50)
fibLevels = array.new_float(6, 0.0)
array.set(fibLevels, 0, pivotHigh)
array.set(fibLevels, 1, pivotHigh - (pivotHigh - pivotLow) * 0.236)
array.set(fibLevels, 2, pivotHigh - (pivotHigh - pivotLow) * 0.382)
array.set(fibLevels, 3, pivotHigh - (pivotHigh - pivotLow) * 0.5)
array.set(fibLevels, 4, pivotHigh - (pivotHigh - pivotLow) * 0.618)
array.set(fibLevels, 5, pivotLow)

// Supertrend Indicator
[supertrendLine, supertrendDirection] = ta.supertrend(3, 14)
plot(supertrendLine, color=supertrendDirection == 1 ? color.green : color.red, title="Supertrend")

// RSI Divergence Detection
rsi = ta.rsi(close, 14)
bullishDivergence = rsi < 30 and ta.lowest(close, 5) == low
bearishDivergence = rsi > 70 and ta.highest(close, 5) == high

// MACD Crossover Detection
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
macdBullishCross = ta.crossover(macdLine, signalLine)
macdBearishCross = ta.crossunder(macdLine, signalLine)

// Candlestick Pattern Detection
bullishEngulfing = close > open[1] and close > high[1] and open < close[1]
bearishEngulfing = close < open[1] and close < low[1] and open > close[1]

morningStar = close[2] < open[2] and (close[1] - open[1]) < ta.atr(5) and close > open[1]
eveningStar = close[2] > open[2] and (close[1] - open[1]) < ta.atr(5) and close < open[1]

doji = math.abs(close - open) < (high - low) * 0.1
spinningTop = (close - open) < (high - low) * 0.3 and (high - low) > ta.atr(5)

// Chart Patterns Detection
headAndShoulders = high[2] > high[4] and high[2] > high[0] and low[3] < low[1] and low[3] < low[5]
doubleTop = high[1] == high[3] and high[2] < high[1]
doubleBottom = low[1] == low[3] and low[2] > low[1]
ascendingTriangle = high > high[1] and low > low[1]
descendingTriangle = low < low[1] and high < high[1]

// Alerts & Plotting
plotshape(bullishEngulfing, location=location.belowbar, color=color.green, style=shape.labelup, title="Bullish Engulfing")
plotshape(bearishEngulfing, location=location.abovebar, color=color.red, style=shape.labeldown, title="Bearish Engulfing")
plotshape(morningStar, location=location.belowbar, color=color.blue, style=shape.triangleup, title="Morning Star")
plotshape(eveningStar, location=location.abovebar, color=color.orange, style=shape.triangledown, title="Evening Star")
plotshape(doubleTop, location=location.abovebar, color=color.red, style=shape.cross, title="Double Top")
plotshape(doubleBottom, location=location.belowbar, color=color.green, style=shape.cross, title="Double Bottom")
plotshape(ascendingTriangle, location=location.belowbar, color=color.blue, style=shape.flag, title="Ascending Triangle")
plotshape(descendingTriangle, location=location.abovebar, color=color.purple, style=shape.flag, title="Descending Triangle")
plotshape(macdBullishCross, location=location.belowbar, color=color.green, style=shape.arrowup, title="MACD Bullish Cross")
plotshape(macdBearishCross, location=location.abovebar, color=color.red, style=shape.arrowdown, title="MACD Bearish Cross")

alertcondition(bullishEngulfing, title="Bullish Engulfing Alert", message="Bullish Engulfing detected!")
alertcondition(bearishEngulfing, title="Bearish Engulfing Alert", message="Bearish Engulfing detected!")
alertcondition(macdBullishCross, title="MACD Bullish Crossover", message="MACD Bullish Cross detected!")
alertcondition(macdBearishCross, title="MACD Bearish Crossover", message="MACD Bearish Cross detected!")

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

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ ข้อกำหนดการใช้งาน