Volume Delta with MACD Filter by KnowledgeJoe

knowledgejoe Updated   
The ta.macd function calculates the MACD line (fast moving average minus slow moving average), the signal line (a moving average of the MACD line), and the MACD histogram (difference between MACD line and signal line), though we're only using the MACD line and signal line for the filter.
The buySignal and sellSignal conditions now include checks to ensure they are in line with the MACD trend. Buy signals are generated when there is a positive volume delta and the MACD line is above the signal line, while sell signals are triggered when there is a negative volume delta and the MACD line is below the signal line.
By filtering your signals with the MACD, your strategy can become more robust by aligning your volume-based signals with the overall market momentum, potentially leading to more reliable trading signals.

Key Changes:
MACD Custom Inputs: The function is used for each of the MACD's parameters: fastLength for the fast moving average, slowLength for the slow moving average, and signalSmoothing for the signal line smoothing. These inputs allow users to customize the MACD settings directly from the script's settings panel.
Adaptive MACD Calculation: By incorporating these inputs into the ta.macd function, the script dynamically calculates the MACD line and signal line based on the user-defined parameters. This customization can significantly enhance the adaptability of your trading strategy to different markets or conditions.
With these modifications, users can fine-tune the MACD indicator's parameters to their specific needs or preferences, potentially improving the effectiveness of your volume delta alerts strategy.
Release Notes:
In this modified script, I added a new user input volumeDeltaThreshold, which allows the user to specify a minimum volume change required to consider a trading signal valid. The buy and sell signal conditions now also check if the volume delta exceeds this threshold (positive for buys, negative for sells), making signals more selective based on user-defined criteria for volume change. This enhancement should help filter out signals during low volume changes, potentially leading to more meaningful alerts.

Knowledge's Joe
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.


The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?