NexusFi: Find Your Edge


Home Menu

 





Fourier series curve fitted to ES data


Discussion in Emini and Emicro Index

Updated
      Top Posters
    1. looks_one Fat Tails with 5 posts (3 thanks)
    2. looks_two aquarian1 with 4 posts (0 thanks)
    3. looks_3 tantrev with 3 posts (4 thanks)
    4. looks_4 BrianBacchus with 3 posts (3 thanks)
      Best Posters
    1. looks_one glennts with 3 thanks per post
    2. looks_two tantrev with 1.3 thanks per post
    3. looks_3 BrianBacchus with 1 thanks per post
    4. looks_4 Fat Tails with 0.6 thanks per post
    1. trending_up 12,239 views
    2. thumb_up 14 thanks given
    3. group 10 followers
    1. forum 22 posts
    2. attach_file 2 attachments




 
Search this Thread

Fourier series curve fitted to ES data

  #11 (permalink)
 cpi65 
UK
 
Experience: None
Platform: -
Posts: 154 since Aug 2010
Thanks Given: 12
Thanks Received: 75


davidcohenphd View Post
FA is useful in many areas, not just those that are related to cycles. But if you are looking for information about it among traders, then you simply don't know enough about the thing to be able to use it profitably. Spend some time learning more about it and how it can be applied. Then you will not need to ask pseudoexperts who never used it but base ther knowledge of it on Wikipedia articles they just read 10 minutes ago, LOL.



Basically I agree with everything he said.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #12 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


davidcohenphd View Post
FA is useful in many areas, not just those that are related to cycles. But if you are looking for information about it among traders, then you simply don't know enough about the thing to be able to use it profitably. Spend some time learning more about it and how it can be applied. Then you will not need to ask pseudoexperts who never used it but base ther knowledge of it on Wikipedia articles they just read 10 minutes ago, LOL.

This is a very general statement with no specific information. You could for example replace the word "FA" with the word "lap dance", and the whole thing still would make sense!

Even if we are not experts of Fourier and Hilbert transforms or Goertzel algorithms, there is nothing bad to try to improve our knowledge. I think the question is justified, whether methods developped be physicists and engineers can be easily applied to trading.

It is true that I understand little about the subject, but further learning would certainly overcharge my limited mathematical capabilities, so I am falling back to heuristics, thing most traders do, when faced with a complex situation. And my heuristics tells me that sentiment and correlations might be more important than assumed cycles.

Reply With Quote
Thanked by:
  #13 (permalink)
 tantrev 
Salt Lake, Utah
 
Experience: Beginner
Platform: MultiCharts
Posts: 10 since Jul 2010
Thanks Given: 1
Thanks Received: 6



Fat Tails View Post
Not sure that a naked DFT will reveil much of a cycle. You could have a look at the Corona Indicators developped by John F. Ehlers. He detrends the time series before analyzing for cycles. I have put the indicators on a 3 min chart for ES for last Friday.

If you look at the cyclical component, there was a dominant cycle with a period of around 28 in the beginning of the session. The lows were tradeable because of the trend that developped later in the day, the highs predicted were not impressive. The problem here is that the cycle amplitude was too small compared to the noise. The signal-to-noise stayed below 4DB during the first two hours, with a large corona, which means that the cyclical signal was week and the noise dominant.

Also to note that the cyclical component, which can barely be identified within price action, changed its period during noon - increased period - and then again prior to the close of the session. if I take into account the daily volatility smile, it is possible that the cycle analysis works better on range charts than time based charts. This is what the shorter cycle in the beginning and the end and the longer cycle in the middle suggest.

But this is just one day of observation. I do not think that cycle analysis is an easy route to success. But it is the sexiest indicator I have ever seen.



Indicators courtesy of @ sefstrat can be downloaded here. They work with both NT 6.5. and NT 7.0

View Download Details - Big Mike's Trading Forum

Alas I think you have convinced me to avoid the stock market, haha. I suppose my dreams of sweeping in on the bottom of supposed cycles and coming out at the crest have been crushed (with good reason.)

Thank you for the technical response - it is nice to hear from an expert and I assure you that experts in this area are far and few in between (at least my limited experience has taught me so.)

Just to clarify for everybody else:
Fourier Series and Fourier Transforms are two totally different things.

A Fourier series is just a function with a collection of these terms:
a1*cos(n*x) + b1*sin(n*x)

where if you keep going, my 8 part Fourier series would look something like this:
a1*cos(n*x) + b1*sin(n*x) + .... a8*cos(n*x) + b8*sin(n*x)

Now Fourier Transforms are ugly sons of bitches. I still don't completely understand them and I honestly don't think most people do. I know in about 3 lines of code, we used them to reconstruct raw MRI data from an MRI machine to the nice pictures you're used to seeing from MRI's but other than that it's kind of a mystery to me. I can tell you that if you have a sound signal, a Fourier Transform will show you the frequencies that are in the signal and their prominence.

Started this thread Reply With Quote
Thanked by:
  #14 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


tantrev View Post
Thank you for the technical response - it is nice to hear from an expert and I assure you that experts in this area are far and few in between (at least my limited experience has taught me so.)

I am certainly not an expert. I am just suspicious. It is easy to give a meaning to any random set of data. If you flip a coin a thousand times, you will find cycles and trends, and it is all smoke and mirrors. Of course, there are real cycles that exist. The daily cycle that repeats itself, which affects volatility in the first place. There is a seasonal cycle, which is obvious for agriculturals and some energy products. Also there is a weekly cycle, which affects the behaviour of trades. The Monday night session typically has a higher volatility than the Tuesday night session, as the news of the weekend need to be digested. If there are cyclical patterns, you also may find them in high frequency analysis of trades.

But then I think that markets are less cyclical and more driven by non-linear dynamics. So the model that I have in mind is not the model of a pendulum, but a multi-agent model, where the agent's behaviour relies on feedback. Such a model can produce temporary oscillations (such as the hog or cattle cycle), but they are instable and dissolve. Timeseries of market data are non-stationary, probability distribution shift from Gaussian to non-Gaussian, when feedback reinforces.

I do not remember, where I have seen this model of a planetary motion with only three or four planets that looked cyclical but then suddenly one of the planets disappeared in outer space... the cyclical behaviour was just an illusion. I also like the Sugarscape simulation, it also shows pseudo-cyclical behaviour, before it drifts away.

Reply With Quote
Thanked by:
  #15 (permalink)
 BrianBacchus 
Las Vegas
 
Experience: Intermediate
Platform: MultiCharts .NET
Trading: CL
Posts: 26 since Oct 2015
Thanks Given: 7
Thanks Received: 37

Thanks for the great read thus far, yes I'm resurrecting an old thread.

The last post does well to explain the difference in Fourier Series (assumed cycles) and the Fourier Transform (which supposedly can be used on aperiodic waves).

I've been playing with these a bit, and believe it or not, at work the extremely awful Thomson Smart platform actually has indicators that utilize Fast Fourier Smoothing (ffS). There's also one called ffD which is described as "the exact analytical derivative of ffS." Unfortunately I would post screen shots but my work, at a financial firm no less, blocks me from accessing this site.

I've been looking at it for a few days now, and particularly smaller time frames. Mostly looking at CL just to see plenty of actions and trades. In that time frame, using it to trade, it's performing pretty well with the system I've developed (and rather quickly).

I'm still trying to recreate the indicators on a better futures trading platform since Thomson Smart is a black box and doesn't reveal coding. Here's what I know about it for sure:

ffS:
1. Uses the Fast Fourier Transfrom (FFT) to break the price "signal" into component sine waves, and translates that data into an array. That data now exists on the frequency domain, no longer on time.
2. ffS, somehow, identifies the first harmonic then depending on your input will keep the first X amount of harmonic frequencies, it then sets all other frequencies to zero.
3. The newly scrubbed frequency spectrum is translated back into the time domain via the Inverse Fourier Transform.
4. The result is a very smooth line (like a moving average) that tracks price. The fewer the harmonics you specify, the flatter the line.

Thus far I've been using the ffS as a filter to decide if long/short positions should be taken. An increasing 5 harmonic ffs means long is available. And vice versa.

ffD:
1. It says "exact analytical derivative" of ffS but I haven't worked out exactly what that means yet. It can be, at least crudely, reconstructed by taking ffs[0] - ffs[1].

I've been using ffD to determine preciesely when to enter trades.

There's some very glaring concerns for these to be fully deployed in a system though. Like, for example, these lines repaint. I know for some that is an instant dealbreaker, but to me, that just makes their value probabilistic instead of determined.

Just laying this out here in case this information is helpful. And if there's any MultiCharts .NET (c#) wizards out there interested in recreating these indicators for that platform, I'd love the help. I'm neither a mathematician nor a programmer naturally.

Reply With Quote
Thanked by:
  #16 (permalink)
 
aquarian1's Avatar
 aquarian1 
Point Roberts, WA, USA
 
Experience: Advanced
Platform: IB and free NT
Broker: IB
Trading: ES
Posts: 4,034 since Dec 2010
Thanks Given: 1,509
Thanks Received: 2,593


BrianBacchus View Post
ffS:
1. Uses the Fast Fourier Transfrom (FFT) to break the price "signal" into component sine waves, and translates that data into an array. That data now exists on the frequency domain, no longer on time.

Thanks for the post.

1. Is the result of a Fourier Transformation a series of over-lapping waves of different amplitudes and frequencies?
2. What does, "That data now exists on the frequency domain, no longer on time." mean?

..........
peace, love and joy to you
.........
Visit my NexusFi Trade Journal Reply With Quote
  #17 (permalink)
 BrianBacchus 
Las Vegas
 
Experience: Intermediate
Platform: MultiCharts .NET
Trading: CL
Posts: 26 since Oct 2015
Thanks Given: 7
Thanks Received: 37


aquarian1 View Post
Thanks for the post.

1. Is the result of a Fourier Transformation a series of over-lapping waves of different amplitudes and frequencies?
2. What does, "That data now exists on the frequency domain, no longer on time." mean?

1. Yes. It breaks the price curve into its component waves. FFT supposedly allows an infinite number of component waves to be generated, I've generally seen most indicators limit the waves generated to ~50.

2. The FFT eliminates time as a datapoint. The result is a bunch of component waves. Graphed, the y-axis would be amplitude, the x-axis frequency. Like so:

https://manual.audacityteam.org/man/plot_spectrum.html

Ehlers' code appears (I could be wrong) to merely record the "strongest" frequency on this plot and determine that as the price curve's "dominant cycle."

The smoothing technique I mentioned merely filters out the "weaker" frequencies to attempt to eliminate signal "noise." Noise in our case meaning outlier price swings that just juke the price action. It's unfounded if this is actually a valid technique, but the quick and dirty results I've used by paper trading it at work makes me think it warrants further study.

Furthermore, I've found a few academic papers that use FFT for data extrapolation. That's getting even further into the pipe dream, but could be really beneficial if the patterns hold, or at least give a good initial jump into the right direction. Here's the only financial indicator I've found that attempts to use FFT in this manner:

https://www.mql5.com/en/code/130

I'm still trying to convert this over to Multicharts .NET to test it.

Reply With Quote
Thanked by:
  #18 (permalink)
 
aquarian1's Avatar
 aquarian1 
Point Roberts, WA, USA
 
Experience: Advanced
Platform: IB and free NT
Broker: IB
Trading: ES
Posts: 4,034 since Dec 2010
Thanks Given: 1,509
Thanks Received: 2,593


BrianBacchus View Post
1. Yes. It breaks the price curve into its component waves. FFT supposedly allows an infinite number of component waves to be generated, I've generally seen most indicators limit the waves generated to ~50.

Ehlers' code appears (I could be wrong) to merely record the "strongest" frequency on this plot and determine that as the price curve's "dominant cycle."

Thanks Brian,

1. I think it would be interesting to see the component waves - like the top 5. plotted in a panel under the price action. The time axis is maintained then each wave would "start" at a different point, but then as each is a different length there will be times when the waves align, eg all peaking at about the same time, and at other times all troughing at together, and other times all perfectly out-of-sync times (peaks coinciding with troughs).

So rather than extrapolation I would like to see the waves and the price movement interaction.

..........
peace, love and joy to you
.........
Visit my NexusFi Trade Journal Reply With Quote
  #19 (permalink)
 BrianBacchus 
Las Vegas
 
Experience: Intermediate
Platform: MultiCharts .NET
Trading: CL
Posts: 26 since Oct 2015
Thanks Given: 7
Thanks Received: 37


aquarian1 View Post
Thanks Brian,

1. I think it would be interesting to see the component waves - like the top 5. plotted in a panel under the price action. The time axis is maintained then each wave would "start" at a different point, but then as each is a different length there will be times when the waves align, eg all peaking at about the same time, and at other times all troughing at together, and other times all perfectly out-of-sync times (peaks coinciding with troughs).

So rather than extrapolation I would like to see the waves and the price movement interaction.

Fwiw, I have something similar to that already. I tweaked Ehlers' code in the link below to plot his "Pwr" variable. It's annoying because it required loads of copy/paste to create 20 (there are 50 possible) plots for it. Not sure if we're supposed to post code in forums but I'll share if you're interested in seeing it in C#. It's by no means a completed work. Here's the paper from Ehlers:

https://www.mesasoftware.com/papers/FourierTransformForTraders.pdf

He tries to use the Fourier Transform as a means to find dominant cycle, an approach that sounds like you might also be interested in seeing. He disregards FFT as an inferior approach to his own MESA research for determining dominant cycle (and therefore a self-setting and correcting indicator lookback period). For me, though, I'm looking at FFT as a noise reduction means.

Ehlers' other work has some pretty good merit. His Fisher Transform indicator is superb at detecting market turns, and there's an edge when instead of taking trading signals just from the turns, you wait for bullish/bearish divergences. It's a great base to build a strategy off of, it just needs some good filtering criteria:

https://www.mesasoftware.com/papers/UsingTheFisherTransform.pdf

Reply With Quote
Thanked by:
  #20 (permalink)
 
sptrader's Avatar
 sptrader 
Colorado
 
Experience: Advanced
Platform: MultiCharts
Broker: IB & Iqfeed
Trading: ES , CL
Posts: 535 since Apr 2010
Thanks Given: 1,097
Thanks Received: 701


I think many traders think that the market moves in cycles. After many many years of screen time, I've come to believe that the market moves in Waves like the ocean, rather than cycles. Cycles imply a fixed period. The period of the market is constantly expanding and contracting. (Like ocean waves).
Cycles do present themselves on occasion but are usually too short lived to be tradable, too short for daytrading anyway.
I talked to Mr. Ehlers many years ago and he told me that his cycle research came from his work in the oil industry. He then adapted it to the markets. (just a bit of trivia).

Reply With Quote
Thanked by:




Last Updated on May 19, 2018


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts