OPEN-SOURCE SCRIPT

Ultra Algo

1 202
‏//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)

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.