OPEN-SOURCE SCRIPT
Heikin-Ashi Trend Matrix [HTM]

Heikin-Ashi Trend Matrix (HTM) uses smoothed Heikin-Ashi calculations combined with a multi-EMA ribbon and ADX filtering to produce a confluence-based scoring system for trend identification and signal generation.

**Mathematical Foundation:**
Heikin-Ashi candles are synthetic candles calculated using averaged formulas: HA-Close = (O+H+L+C)/4, HA-Open = (previous HA-Open + previous HA-Close)/2. These averaged candles naturally smooth price action and make trend direction more visually apparent. HTM applies a secondary smoothing layer (EMA, SMA, or WMA selectable) to the HA values, further reducing noise while preserving trend structure.

The trend matrix evaluates six independent conditions and assigns a point for each: (1) smoothed HA candle direction, (2) price vs fast EMA, (3) fast EMA vs medium EMA alignment, (4) medium EMA vs slow EMA alignment, (5) price vs 200 EMA for long-term trend, and (6) DI+ vs DI- from the ADX system. The total score ranges from 0 to 6 for each direction.
**Signal Logic:**
Signals are generated only when the bullish or bearish score reaches a configurable threshold (default 4 of 6) AND ADX confirms a trending market. This multi-condition confluence approach filters out signals in choppy or low-momentum environments. Signals fire on the first bar where the score threshold is met.
**Features:**
- Smoothed Heikin-Ashi with selectable smoothing type (EMA/SMA/WMA)
- Triple EMA ribbon (fast/medium/slow) with fill coloring
- 200 EMA long-term trend reference
- 6-point confluence scoring system
- ADX trend strength gate
- Dual take-profit levels (TP1/TP2) with ATR-based calculation
- Visual score display with filled/empty dot notation
- Optional bar coloring based on signal strength
**Mathematical Foundation:**
Heikin-Ashi candles are synthetic candles calculated using averaged formulas: HA-Close = (O+H+L+C)/4, HA-Open = (previous HA-Open + previous HA-Close)/2. These averaged candles naturally smooth price action and make trend direction more visually apparent. HTM applies a secondary smoothing layer (EMA, SMA, or WMA selectable) to the HA values, further reducing noise while preserving trend structure.
The trend matrix evaluates six independent conditions and assigns a point for each: (1) smoothed HA candle direction, (2) price vs fast EMA, (3) fast EMA vs medium EMA alignment, (4) medium EMA vs slow EMA alignment, (5) price vs 200 EMA for long-term trend, and (6) DI+ vs DI- from the ADX system. The total score ranges from 0 to 6 for each direction.
**Signal Logic:**
Signals are generated only when the bullish or bearish score reaches a configurable threshold (default 4 of 6) AND ADX confirms a trending market. This multi-condition confluence approach filters out signals in choppy or low-momentum environments. Signals fire on the first bar where the score threshold is met.
**Features:**
- Smoothed Heikin-Ashi with selectable smoothing type (EMA/SMA/WMA)
- Triple EMA ribbon (fast/medium/slow) with fill coloring
- 200 EMA long-term trend reference
- 6-point confluence scoring system
- ADX trend strength gate
- Dual take-profit levels (TP1/TP2) with ATR-based calculation
- Visual score display with filled/empty dot notation
- Optional bar coloring based on signal strength
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.