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

Skrip open-source

Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menerbitkannya sebagai sumber terbuka, sehingga para trader dapat memahami dan memverifikasinya. Hormat untuk penulisnya! Anda dapat menggunakannya secara gratis, namun penggunaan kembali kode ini dalam publikasi diatur oleh Tata Tertib. Anda dapat memfavoritkannya untuk digunakan pada chart

Inggin menggunakan skrip ini pada chart?

Pernyataan Penyangkalan