Halesho bebar

Halesho bebar

//@version=5
// Indicator: Heikin Ashi Smoothed + VWAP Trend Detector
// Author: Grok (for fun and profit)

// --- Heikin Ashi Smoothed ---
length = input.int(14, "Smoothing Length", minval=1, maxval=50)

// محاسبه کندل‌های Heikin Ashi
ha_close = (open + high + low + close) / 4
ha_open = na(ha_open ) ? (open + close) / 2 : (ha_open + ha_close ) / 2
ha_high = math.max(high, math.max(ha_open, ha_close))
ha_low = math.min(low, math.min(ha_open, ha_close))

// نرم‌سازی کندل‌ها با میانگین متحرک
ha_smooth_close = ta.sma(ha_close, length)
ha_smooth_open = ta.sma(ha_open, length)
ha_smooth_high = ta.sma(ha_high, length)
ha_smooth_low = ta.sma(ha_low, length)

// --- VWAP ---
vwap_value = ta.vwap(close)

// --- منطق تشخیص روند ---
// روند صعودی: کندل صاف‌شده صعودی + قیمت بالای VWAP
trend_up = (ha_smooth_close > ha_smooth_open) and (close > vwap_value)
// روند نزولی: کندل صاف‌شده نزولی + قیمت زیر VWAP
trend_down = (ha_smooth_close < ha_smooth_open) and (close < vwap_value)
// خنثی: وقتی هیچ‌کدوم از شرایط بالا برقرار نباشه

// --- خروجی‌ها ---
// رنگ کندل‌ها برای تشخیص بصری
col = trend_up ? color.green : trend_down ? color.red : color.gray
plotcandle(ha_smooth_open, ha_smooth_high, ha_smooth_low, ha_smooth_close, title="HA Smoothed", color=col)

// خط VWAP
plot(vwap_value, "VWAP", color=color.yellow, linewidth=2)

// سیگنال روند
trend_signal = trend_up ? 1 : trend_down ? -1 : 0
plotshape(trend_signal == 1, title="Uptrend", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.tiny)
plotshape(trend_signal == -1, title="Downtrend", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.tiny)

// هشدار برای تغییر روند
alertcondition(trend_signal != trend_signal , title="Trend Change", message="Trend has changed!")

Read More

Share:

Latest News