OPEN-SOURCE SCRIPT

Ultimate Trend Indicator with High Accuracy

//version=6
indicator("Ultimate Trend Indicator with High Accuracy", overlay=true)

// تنظیمات پارامترها
maShortLength = input.int(50, title="Short Moving Average Length")
maLongLength = input.int(200, title="Long Moving Average Length")
maSource = input.source(close, title="MA Source")

rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")

macdFastLength = input.int(12, title="MACD Fast Length")
macdSlowLength = input.int(26, title="MACD Slow Length")
macdSignalLength = input.int(9, title="MACD Signal Length")

atrLength = input.int(14, title="ATR Length")
pmaxATRLength = input.int(10, title="PMax ATR Length")
pmaxMultiplier = input.float(3.0, title="PMax ATR Multiplier")
pmaxMAType = input.string("EMA", title="PMax Moving Average Type", options=["SMA", "EMA", "WMA", "TMA", "VAR", "WWMA", "ZLEMA", "TSF"])

compressionThreshold = input.float(0.5, title="Compression Threshold") // حد فشردگی
volumeFilter = input.float(1.5, title="Volume Filter Multiplier") // فیلتر حجم معاملات

// محاسبه اندیکاتورها
maShort = ta.sma(maSource, maShortLength)
maLong = ta.sma(maSource, maLongLength)
rsi = ta.rsi(close, rsiLength)
[macdLine, signalLine, _] = ta.macd(close, macdFastLength, macdSlowLength, macdSignalLength)
atr = ta.atr(atrLength)
volumeSMA = ta.sma(volume, 20)

// تشخیص فشردگی خطوط
maCompression = math.abs(maShort - maLong) < compressionThreshold
macdCompression = math.abs(macdLine - signalLine) < compressionThreshold

// PMax
getMA(src, length, type) =>
if type == "SMA"
ta.sma(src, length)
else if type == "EMA"
ta.ema(src, length)
else if type == "WMA"
ta.wma(src, length)
else if type == "TMA"
ta.sma(ta.sma(src, math.ceil(length / 2)), math.floor(length / 2) + 1)
else
na

pmaxMA = getMA(close, pmaxATRLength, pmaxMAType)
longStop = pmaxMA - pmaxMultiplier * atr
shortStop = pmaxMA + pmaxMultiplier * atr
dir = 1
dir := nz(dir[1], dir)
dir := dir == -1 and pmaxMA > shortStop[1] ? 1 : dir == 1 and pmaxMA < longStop[1] ? -1 : dir
pmax = dir == 1 ? longStop : shortStop

// تشخیص واگرایی
rsiBullishDivergence = ta.valuewhen(ta.crossover(rsi, rsiOversold), close, 0) > ta.valuewhen(ta.crossover(rsi, rsiOversold), close, 1) and close < close[1]
rsiBearishDivergence = ta.valuewhen(ta.crossunder(rsi, rsiOverbought), close, 0) < ta.valuewhen(ta.crossunder(rsi, rsiOverbought), close, 1) and close > close[1]

// تشخیص شکست سطوح کلیدی
breakoutUp = close > ta.highest(high, 20) // شکست مقاومت
breakoutDown = close < ta.lowest(low, 20) // شکست حمایت

// شرایط تشخیص شروع روند صعودی و نزولی با فیلترهای بیشتر
startUptrend = (maCompression and macdCompression and rsi > 50 and close > pmaxMA and volume > volumeSMA * volumeFilter and close > maShort and close > maLong) or (rsiBullishDivergence and breakoutUp)
startDowntrend = (maCompression and macdCompression and rsi < 50 and close < pmaxMA and volume > volumeSMA * volumeFilter and close < maShort and close < maLong) or (rsiBearishDivergence and breakoutDown)

// نمایش برچسب‌ها فقط در شرایط قوی
plotshape(series=startUptrend and not startUptrend[1], title="Buy Signal", location=location.belowbar, color=color.new(color.green, 0), style=shape.labelup, text="خرید", textcolor=color.white, size=size.small)
plotshape(series=startDowntrend and not startDowntrend[1], title="Sell Signal", location=location.abovebar, color=color.new(color.red, 0), style=shape.labeldown, text="فروش", textcolor=color.white, size=size.small)

// نمایش سطوح PMax و میانگین‌های متحرک
plot(pmax, color=color.orange, title="PMax", linewidth=2)
plot(maShort, color=color.blue, title="Short MA", linewidth=2)
plot(maLong, color=color.red, title="Long MA", linewidth=2)
Bands and ChannelsBreadth IndicatorsCandlestick analysis

오픈 소스 스크립트

진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

차트에 이 스크립트를 사용하시겠습니까?

면책사항