Using Hurst Bandpass Filters


#1

Hello,

I have been trying to reproduce and understand the Hurst (Ormsby) Band-pass filter example as described in The Profit Magic of Stock Transaction Timing book (page 178). I am not as strong at mathematics as I would like to be, however I am trying to learn and understand more as I explore the mathematical approach of cycles demonstrated by Hurst.

I started in Excel and migrated the process to a Metatrader 4 indicator. However I am not sure if I have understood the design process, calculation and the interpretation of the filter output correctly.

I will outline the process I have taken and reach out to those that may understand filters better than I to assist with some questions I have.

Building the bandpass example in Excel (p.181)
First Set:
t=7 (time spacing in weeks)
n=Odd Number of weights = 199
Midpoint weight = (n-1)/2 = (199-1)/2 = 99
wn = (104*pi) / t = 46.6750908533341
Presumably as the filter w1->w4 parameters were in rad/yr 104 is the number of data points on weekly chart per year (52) * 2 ?

Second Set:
Lambda1 L1 = w1/wn = 0.85/46.6750908533341 = 0.018210998
Lambda2 L2 = w2/wn = 0.02678088
Lambda3 L3 = w3/wn = 0.043920643
Lambda4 L4 = w4/wn = 0.052490525

Third Set:
Lambda5 L5 = L1-L2 = -0.008569882
Lambda6 L6 = L4-L3 = 0.008569882

Fourth Set:
RadLambda1 RL1 = 2PIL1 = 0.114423077
RadLambda2 RL2 = 2PIL2 = 0.168269231
RadLambda3 RL3 = 2PIL3 = 0.275961538
RadLambda4 RL4 = 2PIL4 = 0.329807692
RadLambda5 RL5 = 2PIPIL5 = -0.169162681
RadLambda6 RL6 = 2
PIPIL6 = 0.169162681

Calculating the Weights
Calculating the weights (p.182)
weight 1A = (COS(RL3)-COS(RL4)) / (RL6) = 0.094932
weight 1B = (COS(RL2)-COS(RL1 / (RL5) = 0.044836797
weight 1 (A-B) = 0.050096

weight 2A = (COS(RL3WeightNo)-COS(RL4WeightNo)) / (RL6WeightNoWeightNo) = 0.09057818
weight 2B = (COS(RL2WeightNo)-COS(RL1WeightNo) / (RL5WeightNoWeightNo) = 0.044373564
weight 2 (A-B) = 0.046204616
Repeat until weight 99 (midpoint)

Midpoint Weight 100
100A = L3+L4 = 0.096411167
100B = L1 +L2 = 0.044991878
100 A-B = 0.051419289

Then weights 101-199 is a mirror of the first 99, so use weight no 99 for weight 101, no 98 for 102 etc.
Total of all weights = 0.004160528
Total weight / no of weights = 0.00002090717486445620
Then subtract that (0.00002090717486445620) from each of the 199 weights for final weight values.
Weight 1 Final = 1AB (0.050095536) - 0.00002090717486445620 = 0.05007462833448080000 etc…

Excel

Application of the Filter:
I migrated the above logic to Metatrader and created a indicator to plot the filter output. To help aid in checking the output, I created a utility to compute sine wave(s) with an offset, amplitude and frequency and write to Metatrader History files which can be opened as offline charts and the filter indicator is applied.

Test 1:
I created a weekly chart with price data (wavelength) that was 234 bars (4.5 years) long with offset of $10.00 and an amplitude of $10.00.

Observed the filter output that the first 99 and last 99 bars were 0 which I understand is to the expected as that is the midpoint of the weights. The filter output showed an oscillating sine wave the same wavelength with peaks at approx. -0.1595 and troughs at approx. -1.3482 (amplitude of 1.1887)

What I was expecting however was an amplitude of 10 oscillating +5 and -5 around the 0 line.

Test 2:
I then tested adding an additional smaller cycle of 20 weeks and $3 amplitude to the chart.
The filter output still appears to have passed the short 20 week cycle which I didn’t expect.

Questions:
Can anyone who has attempted the bandpass filter comment if I have made the calculations in Excel correctly?

Page 181 says:

These design choices provide 50% or more filter response across a pass-band of frequencies corresponding to sinusoidal components with periods of 2.8 to 6.0 years. Such a filter is suitable for investigation of oscillations of the order of four and a half years’ duration-a dominant element of the price-motion model.

How do the values of the example bandpass (w1 = 0.85, w2 = 1.25, w3 = 2.05, w4 = 2.45) as radians/yr equate to passing cycles of 2.8 and 6.0 years when used on a weekly chart using 7 periods. i.e. if I wanted a bandpass filter on a weekly chart the passed between 30 and 50 weeks, how do I calculate the w1,w2,w3,w4 values as radians/yr ?

I am not sure if I have not calculated the filter weights correctly or if I have made a coding error in the computation of the filter output correctly int MT4.

Should I expect to see the full $10 amplitude of my 4.5 yr price cycle data shown in the output of the filter?
i.e. if the 4.5 years is between w2 and w3 then the amplitude should be pass as 1.0 (ie unchanged).

And if so, should the filter output oscillate evenly around the 0 line, eg $5 peak and -$5 trough, even if the raw data starting price was $10 with the cycle ranging between $10 and $20.

Should I expect the filtered output to have filtered out the $3 amplitude 20 week data that was combined with the 4.5 yr data in the output? (ie if 20 weeks was less than w1 of the filter design it should have been reduced to amplitude to 0.)

Thanks in advance.

Dion


The Financial Wave Theory -- Hurst taken to a whole new level
#2

Hi Dion,

My first advice to you is to download Ormsby’s paper from the internet. The formula in the paper is much easier to understand and code. It is going to take an enormous amount of work to understand what Hurst did, but the rewards in understanding the spectral approach to cyclical analysis is well worth the effort.


#3

Hi Dion,

A for effort and for sharing your work. I have tabled this approach and am pursuing another “more modern” method of time series decomposition that my coworker is more familiar with (we are attempting to backtest it). Because of this, I can’t be of any help on the details at this point. As with most things Hurst, it will likely come to you in stages and not all at once. Keep working and keep us posted.

Curt


#4

“If people understood how simple the mathematical principles really are, they would fall out of their chairs laughing. Granted implementing those principles is somewhat challenging but not insurmountable”.

“It is going to take an enormous amount of work to understand what Hurst did, but the rewards in understanding the spectral approach to cyclical analysis is well worth the effort”.

Okay, William. Which is it? Or is it both an enormous amount of work yet remarkably simple?:blush:


#5

Hi Curt,

It took me an enormous amount of work to understand how simple it really is!:slight_smile:

I certainly agree with your comment about the understanding coming in stages.


#6

Hi Dion,

Here’s a little hint. (2pi)/(.85+1.25).5 = approximately 6 years


#7

Hello again,

First, thanks for the comments William and Curt. Thought I would update my progress.

Thanks William for the hint: If I understand correctly the mid point of the slope between w1 and w2 is where the attenuation is 50% responsive (i.e. the amplitude ratio is 0.5) like wise for mid of w3 and w4.

So if T=2Pi(radians) / w and the filter was designed in radians/year then the point where the band pass filter starts to pass wavelengths (presumably at half their source amplitude) is mid of w3-w4. solving for T gives us 2Pi/2.25 or 2.79 yrs, and then obviously starts to cut off at the w2-w1 values where 2Pi/1.05 is 5.98 yrs.

I managed to find the Ormsby paper from 1961, need to have a read through it.

In terms of the filter output in MT4, I re-read the section in profit magic and think I spotted my error. The time spacing between data points (t) was 7. As I was on a weekly chart I believe I should have been aligning the weights data points with a 7 bar spacing on a weekly chart. Previously I was using every bar for the weights (ie t=1 on a weekly chart).

After adjusting my code I think I have the output doing what I originally was hoping it would do…
The single 4.5yr wave in the filter output oscillates over the 0 line +5 and -5 retaining the source $10 amplitude :slight_smile:

When applied to the other chart with the additional 20 week data it appeared to correctly filter it out whilst retaining the amplitude(10) of the 4.5 year data!! :slight_smile:

I note that because I am on a weekly chart and the filter sampling rate is 7 weeks I only have a data point every 7 bars, as my indicator buffer was 0 for values in between the filter output data plot returns to 0 between the actual output plots so it looks a little strange at the moment…

I presume this is where the curve fitting topics in the book might assist with plotting a smoothed line between the sampling rate spaced filter outputs?

So for now its some more testing with adding a larger than 6yr wave and checking that the band pass filter also attenuates the > 6.0 yr wave to 0 and to try some different size filters, and perhaps then try low pass and comb filters etc…

Dion


#8

Historically, and I don’t know this for sure, it seems Hurst wrote Profit Magic first and then developed the course. Profit Magic is really two books: the first 7/8 and then the last chapter and the appendices. It needs to be understood that all of the work(the amount cannot be overestimated) that Hurst did was based on the mathematical spectral approach. Not only is the principle of extracting price waves summarized(hidden in plain sight) but the proof of the entire theory is outlined…and that proof is pretty absolute imho!
The course, I believe, was Hurst’s attempt to simplify the math, into a visual approach, understood more easily. It is that, however, that can be deceptive because all it is is dividing by 2 and iterating up and down, and making a series of guesses as to what looks right. Remarkably, it works well a great deal of the time. In my opinion, this is not one of those times. The current consensus of the forum is looking here for an 80wk cycle low and that is a logical conclusion in a cycles course visual approach. The problem is that there is no objective proof for that except for the internal consistency of an analysis. The spectral approach, as William has pointed out, is stating the exact opposite, the 80wk wave is approaching a peak, absolutely unless Hurst was wrong…and he wasn’t.
The real difference is the absolute accuracy of the spectral approach v. the mostly accurate visual.
As to the amount of work involved to achieve a moderate degree of understanding…it is enormous! To achieve mastery, a feat attained by less than a handful(I only know two),unimaginable. And yet when the understanding is achieved, the moderate amount, “falling off the chair laughing” is an understatement.
F=ma is a really simple formula. The mental rigor and the work used to have derived was anything but. Simple and complicated at the same time…just like all great science!


#9

The 80wk wave output, as derived spectrally :


#10

Hi Stuart,

Great post. I have a few questions for you.

  1. When you say the “proof of the entire theory is outlined” in Profit Magic, what do you mean? Hurst explains 98% of price behavior using six spectral filters, but as we all know, there is a big difference between explaining prices in the past and predicting prices in the future. What Hurst did was in-sample fitting as opposed to a rigorous out-of-sample backtest. In addition, as I have explained previously in this forum, Hurst’s claim of a 90% success rate is also not a legitimate backtest given the limited number of trades, time period in his evaluation, and overall market movement during this time.

  2. As with most things trading-related, the devil is in the details. Assuming one is willing to spend the time necessary to figure out Hurst’s spectral approach, then replicate it as William and a few others have done, there is no guarantee that this methodology will produce consistent profits because it is not a “trading system” in the strictest sense. How do you choose which frequency (time period) to trade, when do you enter and exit the trade, what are stop loss limits, etc.? These are all detailed parameters that are needed to “prove” the system works. Admittedly, Hurst gives guidelines on these things in both “Profit Magic” and the course material, but there is nothing in either one of these sources that implements specific parameters in a rigorous way to prove his approach works.

  3. You say you know two people who have “mastered” the spectral approach. I have no reason not to believe you and I’m guessing the “proof” is based on some type of verification of their historical results and success (IMO, this is better proof than any backtest). However, how do you know that this success is not a function of their skill in implementing Hurst’s spectral approach compared to the actual approach itself? If the approach itself is the key, it should be verifiable via systematization and an out-of-sample backtest. If a walk-forward analysis using those exact same parameters works extremely well, only then can you claim that Hurst’s spectral approach is “absolutely accurate”. That’s science.

  4. Regarding today’s market environment, how do you know the 18M cycle using spectral analysis is even influencing prices in a significant way? If the amplitude of this cycle is very low compared to other cycles that have been quantified using spectral analysis, then the 18M cycle might be irrelevant at this point. I’m not saying this is the case, I’m just asking how do you know in an objective and quantifiable way what is influencing prices in today’s market?

The above may sound like blasphemy on this forum. It is anything but. I believe the approach Hurst taught in his course is the best trading approach I have ever encountered. My own trading has improved dramatically since learning this approach and using Sentient Trader. Since Hurst’s visual approach is not verifiable, I have engaged a real data “scientist” to help me evaluate Hurst’s spectral approach. He does not believe or disbelieve. He simply wants to evaluate a spectral-based cycles approach in a systematic and quantifiable way through an out-of-sample backtest that analyzes the system from both a return and risk perspective (Sharpe Ratio). If this work, or others’ like it, produces the “spectacular” results as some have claimed, only then can anyone legitimately attest to the absolute accuracy of Hurst’s spectral approach.

Curt


#11

Hi Curt

If you do not mind I would like to respond to some of the great issues you raised, with the understanding that what follows is just my experience and not the Gospel.

I seems to me that there is a misconception as to what constitutes a “spectral” approach to trading. What I learned from studying Hurst is that financial instruments have a dominant mathematical structure. Since the price action is time series data, we know from 300 year old math that it can be decomposed into sine waves. That in and of itself tells one nothing, but Hurst proved that it is a particular average frequency that is dominant in each instrument and that frequency is subject to modulation. He also demonstrated that certain relatively constant mathematical relationships exist with respect to financial data. Without any doubt that is the most important thing I learned from studying Hurst. Without the existence of those relationships, technical analysis based on price action would be impossible.

For me the “proof” of Hurst’s “spectral approach” was running his 4 year filter on the data. He used 44 years of data, I used 140 years of data (more if I count the data you sent me). It perfectly extracted the 4 year price wave over a 100 year period. I then tested the efficacy of those mathematical relationships on countless charts using a huge variety of instruments over various time periods, with unvarying results.

To cut to the chase, the “spectral approach” to cyclical analysis can be done with two moving averages based on the above, an extrapolation technique, and the application of one of Hurst’s basic principles. The trading techniques from the course materials can then be applied to the one’s choice of a trading cycle from the extracted price waves.

There is a lot more of course. While I would not use the term “absolute accuracy,” from my experience a model based on amplitude modulated sine waves more accurately describes the structure of the market for trading or investment purposes than one based on a rigid visual model.

William


#12

Hi Curt
Excellent questions. William has already answered beautifully.
I started by reading Profit Magic, then stumbled upon ST(it was then called the Hurst Trader) and then did the course,
The entire Hurst approach made logical sense. After some practice and use I began to have some success and felt like I had discovered the Holy Grail, except sometimes! I began to realize that my trading success had to do with my confidence in my analysis, but I had no way to verify that my analysis was accurate and so I began to investigate all the usual modalities such as Eliot Wave, Technical Analysis, Merriman, Bressert, etc. I just wanted confirmation that my analysis was correct…and ultimately failed to achieve that goal. David has said many times that the analysis can be wrong and one can make good trading decisions; I believe that that is probably true depending on the time frame but since I was an anal retentive, perfectionist dental implant surgeon, that never sat well with me.
Look at page 152 in Profit Magic and keep in mind the title of chap 3: “Verification of Price Patterns.” Taken together, for me, those two elements approached my goal : to verify my analysis.
There is little or nothing subjective about the extracted waves on p.152…they are all derived from constant and consistent mathematical relationships.When, as William has stated, one has enough data, they can be calculated back for over one hundred years! And then one can back test any trading methodology one wants using whatever criteria, based on those waves.
This brings up a very key point: trading v. analysis. They are completely different. Hurst gave some suggestions on how to use an analysis to enter, manage, and exit trades but this always is based on something. For some it is an analysis as prescribed by the course, for others stochastics, moving averages, Eliot Wave, etc.
Hurst derived his model spectrally and verified it numerically. Part of his model is in figure A!-8. Some of the verification techniques were the bands of Combs filters and Fourier Analysis.
Although Hurst’s model is not predictive in the sense of a Bradley Model or a the ST composite line(both of which are of questionable predictive value IMHO) it is highly descriptive of the past and most importantly, the present. And if you know precisely where you are in the present then when something happens in the present + 30 mins you can know what it means and what to do about it.
For me, its really funny that a market can only do 3 things: go up, down, or sideways…it can do nothing else… and yet the struggle to determine what that direction will be is so great. To have something like p.152 in front of me, makes it much clearer.
A final point : In order to do curve fitting, a linear regression analysis must be used(see PM appendix). I use a stand alone program that is commercially available and is used all over the world. I established an email relationship with its author because I needed help to implement it to my purposes. To say this guy is smart is like saying the sky is blue. As I progressed with my learning, it became clear that I needed the program to do the regressions with a little bit of a twist. I contacted him again, provided some sample data and offered to pay him whatever he required for his time to slightly tweak his program. I explained what Hurst discovered. He came back to me several days later stating that what I wanted to do was futile since the data that was provided to him contained absolutely no cyclicality! Go figure!?@#.


#13

Analyzing an entire data set first and then drawing conclusions from it is considered in-sample fitting in quantitative circles. Doing this incorporates look-ahead bias. Choosing a cycle to trade based on this look-ahead bias is cheating from a back-testing perspective, plus, there is no guarantee that the cycle you choose to trade will remain stable in the future.

I have no misunderstanding about the spectral approach. The misunderstanding (even on Hurst’s part) is what constitutes a legitimate backtest. There is a big difference between a discretionary approach and a systematic approach even if both use spectral analysis as their basis. Neither of Hurst’s two approaches (visual or spectral) were developed to be systematic. There are numerous decisions a trader needs to make along the way in both methods, even though the spectral approach is more quantitatively-based and objective than the visual approach. These decisions incorporate the skill and experience of the trader into the process to produce consistent results. Since these approaches are not systematic, results can only be evaluated based on the word of individual traders and not on objective criteria such as a backtest, although actual historical performance including individual trade detail can also be used and is considered a better indication of future results than a silly old backtest.

I am simply attempting to see if a systematic approach based on spectral analysis can be developed. This is not meant to be superior to a discretionary approach, it is just different. Truth be told, my intuition tells me a skilled and experienced trader using a discretionary approach that includes spectral analysis might produce the best overall results, but I have absolutely no way to prove this.

Curt


#14

Two practical examples:

  1. Take any quasi cyclical indicator RSI, Stochastics,…it does not really matter. Most of these are used with standard inputs,RSI for example length=14…for everything. Hurst showed that each instrument vibrates to a particular frequency. RSI, used with the average frequency for YM, for example on YM, is far more meaningful and predictive than RSI used with the “stock” length. IMHO YM used with the standard length is of minimal utility.
  2. A ST analysis (or any visual analysis using a pattern recognition approach) can be confirmed or unconfirmed by using numerically derived price waves. In my experience it’s never the other way that the pattern recognition derived analysis disproves the spectral.

Also, and this has been discussed in the forum, is the Hurst nominal model versus the custom nominal model debate. The reason the Hurst nominal model works better for the Dow than it does for gold is that the frequency for the two markets are different. A custom nominal model properly developed from a market’s frequency will describe price behavior better than a Hurst nominal model. This is not to discount the Hurst nominal model, but to tailor it to present conditions. The frequency is the key.


#15

Stuart, I don’t disagree with you at all about tuning indicators to the market’s frequency. Regarding the superiority of the spectral over the visual approach, my data scientist guy would look at you blankly and say, “You’ve proven nothing. This is anecdotal evidence”. And yes, I know it is extremely frustrating. So frustrating I have thrown things (not at him because he is great). Now there are ways to structure a backtest that attempt to incorporate the current frequency of the market but that is tricky, because the lookback and dominant cycle sometimes (always?) changes. We have even discussed incorporating corona charts into our analysis to determine the appropriate frequency but the dominant cycle comes and goes so you could be late (just a few days can make a huge difference) or worse yet a cycle that is not picked up in your lookback and corona chart could be driving price action. The best approach is probably segmenting the data and hoping you find a cycle that is consistently dominant both in and out-of-sample, which is similar to what you and William have done (in-sample). This is still very much a work in progress for us so I don’t claim to have all the answers. Also, I am not trying to be difficult. The bar is just set at a higher level when attempting to rigorously backtest systematic strategies.


#16

Curt,

While this debate could continue endlessly, I would like to add a couple of points.

Firstly, I would not consider what I have done as in-sample fitting. The in-sample data was from the period 1922 to 1965, the data period Hurst used in his research. I then applied his conclusions to the out-of sample data periods of 1870 to 1922 and 1965 to present and obtained similar results to the in-sample period thereby confirming his analysis quantitatively.

Secondly, what makes this approach very difficult is that the wave periods are averages, which by definition means the period changes slightly every cycle. What really throws a monkey wrench into the works is when the amplitude of your trading cycle shrinks, which it will do occasionally. Hurst mentions this in Profit Magic. The cycles do not “disappear” or “come and go” as is so widely reported, the amplitude is simply expanding and contracting. It is relatively easy to recognize while it is happening, but I haven’t found a method that anticipates such shrinkage. It is this phenomena that forces the use of a certain amount of discretion.

Rigorous systematic back-testing of this approach is relatively easy (subject to the above uncertainty) if one has the skill and patience to do the coding, which is somewhat complex due to the modulation aspect. When I first started figuring this stuff out, the trading platforms were incapable of doing the necessary math.

The bottom line is that it is very profitable for me as I’m sure ST is for others. Good luck with your research. Remember Hurst said “there are many computational approaches.”

William


#17

Thanks, William. That’s exactly what we have found regarding amplitude. It’s hard to just pick a cycle and trade it since they come and go. And yes, the discretion aspect, even if it is limited, is what makes the systematization so difficult.


#19

It has been quite some time since my original post, but I thought I would come back and update it.
It appears my filter was incorrect in the positioning of weights in the filter. When I changed the number of weights or the time spacing, the filter output would go out of phase and have the wrong amplitudes.

After reading some DSP books and playing around with filters in Octave (open source software similar to Matlab), I discovered how filter coefficients (weights) should appear when plotted (impulse response) for a band pass filter.

For example, the coefficients for the ormbsy bandpass example in profit magic I understand should appear as below (plotted with Octave).

However, when I followed the text in profit magic, the first calculated weight appears as if it should have been one less than the middle weight (and not the first weight), and the second calculated weight two less than the center weight… and so on.

I’m not sure if I just misinterpreted Hurst’s method for calculation of the weights, however this caused my original excel version of the plotted weights to be transposed about the center, with the exception of the center weight).

After updating my MT4 code and attempting the curve fitting between the time spaced filter outputs, I was able to run two different bandpass filters on my combined $10 - 4.5yr and $3 - 20 week price data and extract those cycles. I could see a small amount of ringing (Gibbs phenomenon) in the shorter 20 week filter.

Dion


#20

Hi Dion.

That’s good work! I noticed many, many years ago that Hurst’s description of the weight calculation for the Ormsby filter was backwards. Probably just an editorial oversight.

BTW the relative accuracy of the Ormsby filter can be emulated using significantly fewer weights which makes it more feasible for current analysis.

William


#22

Hi William,

Thank you for the tip on fewer weights. I have been experimenting some more and thought I would update my progress and ask a few more questions.

I tested tapering off the number of weights progressively as I near the end of my price data points. I tested stepping down the number of weights after I could not continue with the initial weight size for each calculation until I run out of data. The chart below shows the filter outputs in green when they are calculated using the set number of weights, then turns red as I begin to reduce them. I observed, as you suggested, that the number of weights can get quite low before the amplitude begins to diminish or sometimes distorts.

I also experimented creating a composite price line using a low pass filter and several band pass filters. I created another set of ‘perfect’ sine wave data. A baseline of $1000 with a 4.5yr - $80 cycle, an 80wk - $50 cycle, a 40wk - $30 cycle and a 20wk - $20 cycle. The band pass filters did a great job of extracting the cycles. I also added a low pass filter to filter everything above about the lowest 4.5 yr filter.

The low pass filter data came in at around $994 (slightly under the $1000 base line) until it tapered off in amplitude rather rapidly as the filter weights were tapered down. After running the parabolic curve fitting between each filter output I took low pass data parabolic fit and added each band pass filter output parabolic fit to produce a composite price line (shown as a dashed orange line under the price data). The shape of the composite line matched the price data quite well, however the composite line sits slightly below that original price, I’m not sure where the slight error is coming from yet.

I am not sure if I have understood how to calculate a low pass and high pass ormsby filter correctly.
I can relate equation (6) from the original ormsby paper to a piece of the process described in PM, but to be honest I couldn’t work out how the method described in PM was derived from the paper.

Equation6

That equation seemed to be computed for the high side of pass band (A) and then subtracted from the low side of pass band (B).

Then there was the center weight computation, weight accumulation, then the mean weight subtracted from each weight.

“example code - similar to original excel explanation”

 for(int i=0;i<mid_point-1;i++)  //0 to midpoint -1 for 0 based arrays stop one element before middle weight
 {
        int j=i+1;  //mimic 1 based array index
        A = (MathCos(R_L3*j) - MathCos(R_L4 * j)) / (R_L6 * j * j);
        B = (MathCos(R_L2*j) - MathCos(R_L1 * j)) / (R_L5 * j * j);
        Wt[mid_point-1-j] = A-B;
        Wt[mid_point-1+j] = A-B;    //mirror the weights on the other side of array about the centre
        SumWt = SumWt + Wt[mid_point-1-j] + Wt[mid_point-1+j];  //accumulate the weights
  }
   
   Wt[mid_point-1] = (L3 + L4) - (L1 + L2);  //compute the center weight
   SumWt = SumWt + Wt[mid_point-1];  //add the special centre weigth to the accumulator
   Final_SumWt = SumWt / NoOfWeights_i;  //divide weight sum by no. of weights 

  for(int i=0;i<NoOfWeights_i;i++)
  {
     Wt[i] = Wt[i] -  Final_SumWt;  //subtract final sum wts mean from each weight.
  }

In attempting to create high pass and low pass filters, I came up with the following changes to the band pass method above.

For low-pass, I would use only (A) in the loop, (B) would be 0, with w3 and w4 being the frequency roll off and terminate. For the center weight I used (L3+ L4) (leaving off the L1+L2). For the subtraction of the mean from each weight, I tried subtracting the mean / 2.

For the high-pass, I would use only (B) in the loop, (A) would be 0, For the center weight I used (L2+L1)/2. For the subtraction of the mean from each weight, I tried Wt[i] - Final_SumWt from each weight with the exception of 1-(Wt[i] - (Final_SumWt*2) for the center weight.

The impulse responses of low-pass (top), high-pass (middle), and band-pass (bottom) are shown below.

I am not sure if I have the correct methods for calculation of the low-pass and high-pass filters?

My next step is to find the optimal weight counts to stop the tapering at then begin projecting to now time and perhaps slightly into the future. Is it best to just take some type of average of the previous cycle(s) wavelength and amplitude when projecting forward? Obviously in this example with perfect sine wave data, there is no amplitude modulation occurring to deal with.

Dion