OPEN-SOURCE SCRIPT
Volume Width Based Candles

Overview
This indicator reimagines traditional candlestick charts by adjusting the horizontal width of each candle based on the bar’s trading volume. In other words, candles with higher volume appear wider, while those with lower volume are drawn narrower. This extra visual dimension can help traders quickly identify bars with significant volume relative to a defined lookback period.
Key Components
Volume Normalization:
The script calculates the highest volume over a user-defined lookback period (default is 100 bars).
Each bar’s volume is then normalized by dividing it by this maximum value. The result is a value between 0 and 1 that represents how the current volume compares to the maximum over the lookback.
Variable Candle Width Calculation:
A base multiplier (default set to 0.4) is used to control how much the volume influences the candle width.
The normalized volume is multiplied by this multiplier to compute an offset value.
Instead of using timestamps (which could lead to drawing objects too far into the future), the script uses the bar_index (the sequential index of bars) to determine the left and right positions of each candle.
The left and right x–positions are calculated by subtracting and adding the offset from the current bar index, respectively.
Candle Body & Wick Drawing:
Candle Body:
The body is drawn using box.new as a rectangle.
The top and bottom of the box are determined by the higher and lower values of the open and close prices.
The color of the candle is set based on whether the bar is bullish (green) or bearish (red).
Wicks:
The upper wick is drawn from the high of the bar down to the top of the body.
The lower wick is drawn from the low up to the bottom of the body.
These are created using line.new at the current bar index.
Handling Edge Cases:
The indicator includes conditions to avoid drawing errors on the very first bar (or any bar where prior data is unavailable).
It also converts the calculated x–coordinates (which are derived from the bar index plus a floating point offset) to integers since box.new requires integer values for positioning.
What It Tells the Trader
Volume Visualization:
Wider candles indicate bars where trading volume is high relative to recent history, potentially highlighting periods of increased market activity.
Narrower candles suggest lower volume, which can signal less interest or participation during that bar.
Contextual Price Action:
By integrating volume into the visual representation of each candle, traders get an immediate sense of the strength behind price movements.
This can be particularly useful for spotting potential breakouts, reversals, or confirming trends when analyzed alongside traditional price-based indicators.
Customization Options
Volume Lookback Period:
You can adjust the number of bars considered when determining the maximum volume. A shorter period may be more responsive to recent changes, while a longer period provides a broader context.
Base Width Multiplier:
Adjusting this multiplier changes how pronounced the effect of volume is on the candle’s width. Increasing it will make high-volume candles even wider, and decreasing it will reduce the difference between high and low volume candles.
Final Thoughts
This indicator is a creative way to overlay volume information directly onto the price chart without the need for separate volume bars. It provides an at-a-glance understanding of market activity and can be a valuable addition to a trader’s toolkit, especially for those who prefer visual cues integrated with price action. However, due to limitations (like the maximum number of drawn boxes), it’s best used on charts with a moderate amount of historical data or with appropriate adjustments to manage performance.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
للوصول السريع إلى الرسم البياني، أضف هذا النص البرمجي إلى مفضلاتك - تعرف على المزيد هنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
للوصول السريع إلى الرسم البياني، أضف هذا النص البرمجي إلى مفضلاتك - تعرف على المزيد هنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.