"Trading is statistics and time series analysis." This blog details my progress in developing a systematic trading system for use on the futures and forex markets, with discussion of the various indicators and other inputs used in the creation of the system. Also discussed are some of the issues/problems encountered during this development process. Within the blog posts there are links to other web pages that are/have been useful to me.
Pages
▼
Saturday, 19 February 2011
A leading signal for oscillators #2
I have now completed coding of the leading oscillator signal (c++ .oct file) and shown above are the results.
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.
Hi,
ReplyDeleteThanks for adding me to your blog roll.
It would be instructive to see how your filter handles a DSP "torture test"! I am sure you have passed steps and pulses through it, how about a chirp?
In fact, I should go look for a suite of such signals for testing purposes.
How do you hold the lag constant for various frequencies? Is there some intrinsic feature of the filter or do you employ some feedback in the filter constants?
Hello BlueEventHorizon,
ReplyDeletePlease accept my apologies for the late reply to this comment; I had no idea it was awaiting moderation until today.
I have not put my filters to a DSP "torture test" as you suggest, but I agree that it would be a good idea to create a suite of such tests. This has now been added to my list of things to do.
In direct reply to your question about lag, the answer is - it depends. For some filters the lag is constant no matter what the frequency and this is a feature of the filter. Given that the lag is constant and known it can be compensated for. For other filters the lag can vary according to the frequency/period. Monte Carlo simulation of the filter at varying, known periods is conducted to measure the amount of lag at each period and a "compensatory look up table" is derived for on the fly lag compensation of real data, given its current, measured period. Period measurement is obtained via the Hilbert transformation.