OPEN-SOURCE SCRIPT
Heiken Ashi Trend Line

Heiken Ashi Trend Line
Heiken Ashi candles are great for reading trend, but you lose the real price action in exchange for the smoothing. This indicator gives you the best of both: keep your regular candles on the chart, and overlay a single line that tracks the Heiken Ashi trend.
What it plots
A single line drawn at the midpoint of the Heiken Ashi body (the average of HA Open and HA Close). The line is colored green when the current HA candle would be green (HA Close ≥ HA Open) and red when it would be red. You get the HA trend signal without giving up real candle visibility.
Why the midpoint
The midpoint of the HA body smooths naturally because HA Open is itself a running average of prior HA values. Mixing it with HA Close produces a line that tracks price closely but with less noise than a raw close-based plot. No length parameter required, no arbitrary smoothing to tune.
Offset setting
An adjustable offset (as a percentage of price) lets you shift the line above or below your candles so it doesn't overlap the price action. Percentage-based scaling means the same setting looks consistent across any ticker. 0.1% is visually similar on SPY as it is on a $20 stock. Set to 0 to keep it anchored to price, positive to push it above, negative to push it below.
How to use
Works on any ticker and any timeframe. No configuration required
Use the color to read trend direction at a glance
Use the slope as confirmation of momentum strength
Pairs well with your existing setups since it doesn't clutter the chart
A note on transition bars
On bars where HA flips direction, the line's slope may briefly disagree with its color. This is the Heiken Ashi math being honest. HA Open on the first bar of a new direction is anchored near the prior body. It's rare and it's not a bug.
Heiken Ashi candles are great for reading trend, but you lose the real price action in exchange for the smoothing. This indicator gives you the best of both: keep your regular candles on the chart, and overlay a single line that tracks the Heiken Ashi trend.
What it plots
A single line drawn at the midpoint of the Heiken Ashi body (the average of HA Open and HA Close). The line is colored green when the current HA candle would be green (HA Close ≥ HA Open) and red when it would be red. You get the HA trend signal without giving up real candle visibility.
Why the midpoint
The midpoint of the HA body smooths naturally because HA Open is itself a running average of prior HA values. Mixing it with HA Close produces a line that tracks price closely but with less noise than a raw close-based plot. No length parameter required, no arbitrary smoothing to tune.
Offset setting
An adjustable offset (as a percentage of price) lets you shift the line above or below your candles so it doesn't overlap the price action. Percentage-based scaling means the same setting looks consistent across any ticker. 0.1% is visually similar on SPY as it is on a $20 stock. Set to 0 to keep it anchored to price, positive to push it above, negative to push it below.
How to use
Works on any ticker and any timeframe. No configuration required
Use the color to read trend direction at a glance
Use the slope as confirmation of momentum strength
Pairs well with your existing setups since it doesn't clutter the chart
A note on transition bars
On bars where HA flips direction, the line's slope may briefly disagree with its color. This is the Heiken Ashi math being honest. HA Open on the first bar of a new direction is anchored near the prior body. It's rare and it's not a bug.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.