Pine Script creates a custom volume indicator with several features, including:
SMA of Volume: It calculates the simple moving average (SMA) of the volume, which helps identify trends and determine if the current volume is above or below the average.
ATR (Average True Range): It calculates the ATR, which measures market volatility over a defined period.
Bullish/Bearish Volume Coloring: The script colors the volume bars depending on whether the price is moving up (bullish) or down (bearish), and whether the volume is above or below the SMA of volume.
Session Highlighting: It defines two major trading sessions:
NYSE (New York Stock Exchange) session from 9:30 AM to 4:00 PM Eastern Time. LSE (London Stock Exchange) session from 8:00 AM to 4:30 PM GMT. These sessions are highlighted with background colors for easy identification. Plotting: The volume is plotted as a histogram with varying colors depending on price movement and volume relative to its SMA. The ATR is also plotted as a purple line, and the SMA of volume is displayed as an orange line.
Background Colors: Background colors are applied during the NYSE and LSE sessions to visually differentiate between these trading periods.
Here's a breakdown of each section:
Key Inputs: smaLength and atrLength: User-defined values for the lengths of the SMA and ATR calculations. Main Calculations: smaVolume: The SMA of the volume over the user-defined length (smaLength). atrValue: The Average True Range over the user-defined length (atrLength). Color Logic for Volume Bars: If the current close is higher than the previous close, the volume is considered bullish, and the bar is colored green. If the volume is above the SMA, it’s a darker green; otherwise, it’s a lighter shade. If the current close is lower than the previous close, the volume is considered bearish, and the bar is colored red. If the volume is above the SMA, it’s a darker red; otherwise, it’s a lighter red. Plotting: The script plots the volume as a histogram with dynamic coloring. The SMA of the volume is plotted as a line. ATR is plotted as a purple line for reference. Background Color Highlighting: The background is colored green during the NYSE session and blue during the LSE session.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda — ketahui lebih lanjut di sini.
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda — ketahui lebih lanjut di sini.
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.