OPEN-SOURCE SCRIPT

Volume Standard Deviation Alert Gus

Purpose
The script detects and alerts traders when the volume of a trading asset significantly exceeds a calculated threshold based on the standard deviation of volume over a specified lookback period. It optionally filters these alerts based on whether the price action is bullish or bearish.

Key Components
Inputs
lookback (default: 20)
The number of bars to consider when calculating the moving average and standard deviation of volume.

stdDevFactor (default: 2.0)
The multiplier for the standard deviation to determine the threshold for a volume spike.

alertOnClose (default: true)
Determines whether alerts should only be triggered after the bar has closed.

checkBullBear (default: false)
Enables filtering of alerts based on the bullishness or bearishness of the bar.

Calculations
volSMA
The simple moving average (SMA) of the volume over the lookback period.

volStd
The standard deviation of the volume over the lookback period.

threshold
The alert threshold is calculated as:

Threshold
=
volSMA
+
(
stdDevFactor
×
volStd
)
Threshold=volSMA+(stdDevFactor×volStd)
isBullish & isBearish
Determines whether the current bar is bullish (close > open) or bearish (close < open).

volumeSpikeCondition
A condition that triggers when the current volume exceeds the calculated threshold.

bullishCondition & bearishCondition
Refines the spike condition by requiring the bar to be bullish or bearish when checkBullBear is enabled.

finalCondition
The ultimate alert condition based on the user’s preference for bullish/bearish filtering.

finalTrigger
Ensures the alert only triggers at bar close if alertOnClose is set to true.

Visualization
Plots the SMA of the volume (volSMA) and the threshold line (threshold), helping traders visually understand the conditions.
Histograms the current volume and colors the bars:
Red: Volume exceeds the threshold.
Blue: Volume is below the threshold.
Alerts
The script generates an alert message when the finalTrigger condition is met:

"Bullish Volume Spike!" if the bar is bullish.
"Bearish Volume Spike!" if the bar is bearish.
"High Volume Spike!" if no bull/bear filter is applied.
Alerts are sent using alert() with the message and set to trigger once per bar close.

Usage
Traders can use this script to identify unusual volume activity, which often precedes significant price movements.
Customizability allows traders to tune the lookback period, standard deviation multiplier, and whether to filter for bullish/bearish spikes.
Visual and audible cues help in identifying important market events in real time.
This indicator is particularly useful for spotting market breakouts or breakdowns driven by high trading activity.
Volume

Скрипт с открытым кодом

В истинном духе TradingView автор этого скрипта опубликовал его с открытым исходным кодом, чтобы трейдеры могли понять, как он работает, и проверить на практике. Вы можете воспользоваться им бесплатно, но повторное использование этого кода в публикации регулируется Правилами поведения. Вы можете добавить этот скрипт в избранное и использовать его на графике.

Хотите использовать этот скрипт на графике?

Отказ от ответственности