OPEN-SOURCE SCRIPT
Ultra Algo

//version=5
indicator("ترند + دعم", overlay=true)
length = input.int(20, title="عدد الشموع للتحليل")
lookback = input.int(50, title="عدد الشموع للترند")
// حساب أعلى وأدنى سعر لخط الدعم
lowestLow = ta.lowest(low, length)
// إيجاد قاعين (لرسم ترند صاعد) أو قمتين (لرسم ترند هابط)
var float trendLineStart = na
var float trendLineEnd = na
var int trendStartBar = na
var int trendEndBar = na
// ترند صاعد: نبحث عن قاعين
for i = 1 to lookback
if low < low[i+1] and low < low[i-1]
if na(trendLineStart)
trendLineStart := low
trendStartBar := bar_index
else
trendLineEnd := low
trendEndBar := bar_index
break
// ترند هابط: نبحث عن قمتين
var float downTrendStart = na
var float downTrendEnd = na
var int downStartBar = na
var int downEndBar = na
for i = 1 to lookback
if high > high[i+1] and high > high[i-1]
if na(downTrendStart)
downTrendStart := high
downStartBar := bar_index
else
downTrendEnd := high
downEndBar := bar_index
break
// رسم خط الترند الصاعد
if not na(trendLineStart) and not na(trendLineEnd)
line.new(x1=trendStartBar, y1=trendLineStart, x2=trendEndBar, y2=trendLineEnd, color=color.green, width=2, extend=extend.right)
// رسم خط الترند الهابط
if not na(downTrendStart) and not na(downTrendEnd)
line.new(x1=downStartBar, y1=downTrendStart, x2=downEndBar, y2=downTrendEnd, color=color.red, width=2, extend=extend.right)
// دعم
plot(lowestLow, title="خط الدعم", color=color.blue, linewidth=2)
indicator("ترند + دعم", overlay=true)
length = input.int(20, title="عدد الشموع للتحليل")
lookback = input.int(50, title="عدد الشموع للترند")
// حساب أعلى وأدنى سعر لخط الدعم
lowestLow = ta.lowest(low, length)
// إيجاد قاعين (لرسم ترند صاعد) أو قمتين (لرسم ترند هابط)
var float trendLineStart = na
var float trendLineEnd = na
var int trendStartBar = na
var int trendEndBar = na
// ترند صاعد: نبحث عن قاعين
for i = 1 to lookback
if low < low[i+1] and low < low[i-1]
if na(trendLineStart)
trendLineStart := low
trendStartBar := bar_index
else
trendLineEnd := low
trendEndBar := bar_index
break
// ترند هابط: نبحث عن قمتين
var float downTrendStart = na
var float downTrendEnd = na
var int downStartBar = na
var int downEndBar = na
for i = 1 to lookback
if high > high[i+1] and high > high[i-1]
if na(downTrendStart)
downTrendStart := high
downStartBar := bar_index
else
downTrendEnd := high
downEndBar := bar_index
break
// رسم خط الترند الصاعد
if not na(trendLineStart) and not na(trendLineEnd)
line.new(x1=trendStartBar, y1=trendLineStart, x2=trendEndBar, y2=trendLineEnd, color=color.green, width=2, extend=extend.right)
// رسم خط الترند الهابط
if not na(downTrendStart) and not na(downTrendEnd)
line.new(x1=downStartBar, y1=downTrendStart, x2=downEndBar, y2=downTrendEnd, color=color.red, width=2, extend=extend.right)
// دعم
plot(lowestLow, title="خط الدعم", color=color.blue, linewidth=2)
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.