The purpose of this code is to graph a volume simple moving average (sma) and it's first and second derivatives to provide traders with additional information that might determine if volume is converging or diverging with price. The yellow line represents the volume sma, the red line represents the first derivative or the rate of change of the volume and the green line represents the second derivative or acceleration of volume. For long term trading, if the yellow line is "trending" upwards with higher highs and higher lows it means that volume is supporting the over all long term price trend. If the volume is decreasing over the long term then it is not supporting the current price trend. The first and second derivatives may help short term weekly traders confirm price movements. There are several different conditions to look for:
First (Red) ++ Second (Green) --, Trading volume at the current price has "peaked" and the price may reverse soon. First (Red) -- Second (Green) ++, Trading volume at the current price has "troughed" and the price may reverse soon. First (Red) + Second (Green) +, Trading volume is not only increasing but it's accelerating which might confirm a large price movement. First (Red) - Second (Green) -, Trading volume is not only decreasing but it's decelerating which might indicate little to no price movement.