


The topmost chart shows idealised prices as a combination of trend and sine wave with the highpass filter below. Lead 1 and lead 2 are the 1 and 2 period leading signals of the original "price" in blue and the highpass filter in black (see legend in the plot).
The second chart shows the same, but with no trend component added to the "price." Plotting this way makes it easier to see that the indicator lines are exactly in phase with "price" and its leads.
The last chart is a check of my algorithm coding. Applying the highpass filter, and then smoothing it, results in various degrees of phase lag or lead in the basic indicator, dependent upon the period of the underlying signal. Using Monte Carlo techniques to determine the lag/lead at periods of interest I have adjusted the phase of the final indicator outputs such that the indicator adapts to the amount of lag/lead by applying a phase correction. This final chart is just a check of this phase correcting algorithm. As can be seen, once the algorithm calculations settle down, the algorithm correctly calculates the lag/lead to apply as evidenced by the hp_sine values completely overwriting the original "price" values. This algorithm is used in the .oct function used to create the top two charts of the highpass filter.