OPEN-SOURCE SCRIPT

ترکیب اندیکاتورها برای سیگنال‌های پیشرفته

77
//version=5
indicator("ترکیب اندیکاتورها برای سیگنال‌های پیشرفته", overlay=true)

// تنظیمات پارامترهای اندیکاتورها
fast_length = input.int(9, title="طول دوره MA سریع")
slow_length = input.int(21, title="طول دوره MA کند")
rsi_length = input.int(14, title="طول دوره RSI")
macd_fast_length = input.int(12, title="طول دوره MACD سریع")
macd_slow_length = input.int(26, title="طول دوره MACD کند")
macd_signal_length = input.int(9, title="طول دوره سیگنال MACD")

// محاسبه میانگین‌های متحرک
fast_ma = ta.sma(close, fast_length)
slow_ma = ta.sma(close, slow_length)

// محاسبه RSI
rsi = ta.rsi(close, rsi_length)

// محاسبه MACD
[macd_line, signal_line, _] = ta.macd(close, macd_fast_length, macd_slow_length, macd_signal_length)

// شرایط برای سیگنال‌ها
buy_condition = (ta.crossover(fast_ma, slow_ma)) and (rsi < 30) and (macd_line > signal_line)
sell_condition = (ta.crossunder(fast_ma, slow_ma)) and (rsi > 70) and (macd_line < signal_line)

// نمایش سیگنال‌ها روی نمودار
plotshape(series=buy_condition, title="سیگنال خرید", location=location.belowbar, color=color.green, style=shape.labelup, text="خرید")
plotshape(series=sell_condition, title="سیگنال فروش", location=location.abovebar, color=color.red, style=shape.labeldown, text="فروش")

// هشدارها برای سیگنال‌ها
alertcondition(buy_condition, title="سیگنال خرید", message="سیگنال خرید ایجاد شد!")
alertcondition(sell_condition, title="سیگنال فروش", message="سیگنال فروش ایجاد شد!")

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.