Lorenzooo

Lorenzooo

//@version=5
indicator("روند ساده با میانگین متحرک", overlay=true)

// تنظیمات پارامترهای ورودی
length_short = input.int(9, title="دوره کوتاه‌مدت")
length_long = input.int(21, title="دوره بلند‌مدت")

// محاسبه میانگین متحرک ساده (SMA) و نمایی (EMA)
sma_short = ta.sma(close, length_short)
ema_long = ta.ema(close, length_long)

// رسم میانگین متحرک‌ها روی نمودار
plot(sma_short, color=color.blue, title="SMA کوتاه‌مدت")
plot(ema_long, color=color.red, title="EMA بلند‌مدت")

// تشخیص روند
trend = na
if (sma_short > ema_long)
trend := 1 // روند صعودی
else if (sma_short < ema_long)
trend := -1 // روند نزولی
else
trend := 0 // روند خنثی

// نمایش روند روی نمودار
bgcolor(trend == 1 ? color.new(color.green, 90) : trend == -1 ? color.new(color.red, 90) : na, title="روند")

// نمایش سیگنال‌ها
plotshape(series=trend == 1, title="روند صعودی", location=location.belowbar, color=color.green, style=shape.labelup, text="صعودی")
plotshape(series=trend == -1, title="روند نزولی", location=location.abovebar, color=color.red, style=shape.labeldown, text="نزولی")

Read More

Share:

Latest News