DYO: Histogram of 2 shifted Moving Averages
|
Q: Appreciate if you could you please help on a DYO that shows the spread/difference of 2 shifted moving averages in the form of a histogram.
A: I assume you have 2 different moving average objects so that they can be forward shifted independently. Here is a solution.
Line A and B read the study values from the Moving Averages on the chart. In the example the 6 period average is plotted in Blue and the 9 period average is plotted in Red and they have different forward shift parameters.
Line C calculates the spread between the two averages, and initializes the DYO paint can to the color Red.
Line D tests to see if the spread is above zero and if so, it changes the default paint can color to a Green.
Line E plots the spread which was stored in GV[3] as a histogram using the default paint can color which is either Red or Green.
Last modified 8/8/08 11:17 AM
|