Trader4TOS
Member
For those that need this as an individual function the VSA indicator should fit your needs.
The Volume Spike Alert Indicator is designed to identify and alert you when there is a significant increase in volume compared to the average volume over a specified number of bars. Here's a breakdown of how the indicator works:
Remember to use the indicator in conjunction with other technical analysis tools and strategies for a comprehensive analysis of the market.
The Volume Spike Alert Indicator is designed to identify and alert you when there is a significant increase in volume compared to the average volume over a specified number of bars. Here's a breakdown of how the indicator works:
- Input Parameters:
- alert_volume: This parameter defines the minimum volume required to trigger an alert. You can adjust this value based on your preference.
- alert_bars: This parameter determines the number of bars to consider when calculating the average volume and standard deviation.
- Calculating Average Volume and Standard Deviation:
- The indicator calculates the average volume using the Average function, which takes the volume input and the specified number of bars (alert_bars).
- It also calculates the standard deviation of the volume using the StDev function with the same input and number of bars.
- Determining the Volume Threshold:
- The volume threshold is calculated by adding twice the standard deviation to the average volume. This threshold value helps identify significant volume spikes.
- Volume Spike Alert:
- The indicator triggers an alert using the alert function when the volume exceeds the volume threshold (volume >= volume_threshold). The alert message is set to "Volume Spike Alert!" and it uses a ding sound.
- Plotting the Volume Threshold:
- The volume threshold is plotted on the chart using the plot function. It is represented as a line with a white color.
- Highlighting Bars with Volume Spikes:
- The bars with volume spikes are highlighted by assigning a yellow background color using the AssignBackgroundColor function. When the volume of a bar exceeds the volume threshold, that bar will have a yellow background.
Remember to use the indicator in conjunction with other technical analysis tools and strategies for a comprehensive analysis of the market.
Ruby:
#Created by Trader4TOS
# Volume Spike Alert Indicator for Thinkorswim
# Define inputs
input alert_volume = 100000; # The minimum volume to trigger an alert
input alert_bars = 2; # The number of bars to check for volume spikes
# Calculate volume average and standard deviation
def average_vol = Average(volume, alert_bars);
def stdev_vol = StDev(volume, alert_bars);
# Calculate the volume threshold for triggering an alert
def volume_threshold = average_vol + (stdev_vol * 2);
# Alert when volume exceeds threshold
alert(volume >= volume_threshold, "Volume Spike Alert!", Alert.BAR, Sound.Ding);
# Plot the volume threshold on the chart
plot threshold = volume_threshold;
threshold.SetDefaultColor(Color.WHITE);
threshold.SetStyle(Curve.FIRM);
# Highlight bars with volume spikes
AssignBackgroundColor(if volume >= volume_threshold then Color.YELLOW else Color.CURRENT);
Last edited: