Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (degenerate_762), 1,114 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Strategies based on Ehlers' work #446421
10/15/14 06:56
10/15/14 06:56
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Hi everyone

The purpose of this thread is to start a discussion and hopefully some collaboration around the work of John Ehlers. I have been reading a lot of his work the last couple of months, and I am very interested in pursuing it further. It appeals because it has a solid theoretical foundation.

I'll kick things off with his "Even Better Sine Wave" (EBSW) as described in "Cycle Analytics for Traders". The EBSW is a variant of his Roofing Filter, but uses a single-pole high pass filter connected to the super smoother. After the data is filtered, the 3-bar average wave amplitude and power are calculated and the output is then computed by normalizing the averaged amplitude to the square root of the average power. The result is an oscillator-style indicator that swings between +1 and -1.

Here is my code (comments and suggestions much appreciated):

Code:
// =====EHLERS' EVEN BETTER SINEWAVE=====

function run()
{

//High pass filter cyclic components whose periods are shorter than duration input
vars Price = series(price());
var Duration = 40; //optimize(40, 10, 100); //max length of trend trade
vars HP = series(HighPass1(Price, Duration));

//Smooth with super smoother
vars Filter = series(Smooth(HP, 10));

//3-bar average of wave amplitude and power
vars Wave = series((Filter[0] + Filter[1] + Filter[2])/3);
vars Pwr = series((Filter[0]*Filter[0] + Filter[1]*Filter[1] + Filter[2]*Filter[2])/3);

//Normalize average wave amplitude to square root of the average power
vars ebsw = series(Wave[0]/sqrt(Pwr[0]));
plot("ebsw", ebsw, NEW, RED);

}



Attached is a chart showing what it looks like (EUR/USD daily bars from 2012).

The only input parameter is the cutoff period of the single-pole highpass filter (Ehlers' default is 40). Longer periods cause the oscillator to swing less frequently. Ehlers interprets the cutoff period as being something like the maximum expected trend duration - but I don't see how you can "expect" the duration of a trend! Seems more sensible to optimize this parameter over a robust range of values in a trading system.

Ehlers says "hold a long position when the indicator value is near +1 and hold a short position when it is near -1." Obviously this is not enough to create a trading system, and the indicator is much more useful when the market is trending, as opposed to cycling.

I think this filter could have an application in a system that follows trends, but it needs additional filters to really make it useful.

I'd love to hear what others think of this!

Attached Files EBSW.png
Re: Strategies based on Ehlers' work [Re: boatman] #446423
10/15/14 09:10
10/15/14 09:10
Joined: Oct 2014
Posts: 42
DEVON
S
scotpip Offline
Newbie
scotpip  Offline
Newbie
S

Joined: Oct 2014
Posts: 42
DEVON
I'm up for this - Ehlers does seem one of the most interesting innovators in the field.

For anyone who'd like to get an overview of what he's up to, here's a non-technical seminar where he explains what he feels his approach offers.

https://www.youtube.com/watch?v=BR5pDiPYsnw

My maths is limited, so I won't be able to help much with coding up new indicators, but I'm happy to feed back any insights from our experiments.

A quick question - do we have the latest MESA filters that are in the public domain? If not, is there any way we could get them into Lite-C?

Re: Strategies based on Ehlers' work [Re: scotpip] #446433
10/15/14 11:31
10/15/14 11:31
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Hey scotpip, fantastic that you are interested in this! Thanks for sharing the link, I'm watching it as I type this.

Regarding the latest MESA filters - do you mean these ones? http://www.mesasoftware.com/technicalpapers.htm Most of those are available in Zorro, or are able to be assembled using the existing tools in Zorro.

Re: Strategies based on Ehlers' work [Re: boatman] #446438
10/15/14 12:52
10/15/14 12:52
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Just finished watching the video that scotpip shared. It is a recording of Ehlers explaining some of the key points from his most recent book "Cycle Analytics for Traders". Even if you've read this book and understood the material, I highly recommend watching the video. Ehlers explains some of the important concepts very clearly and it can only help increase comprehension.

Re: Strategies based on Ehlers' work [Re: scotpip] #446439
10/15/14 12:59
10/15/14 12:59
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Also, Ddlv coded some of Ehlers' filters here - http://www.opserver.de/ubb7/ubbthreads.p...true#Post430829

Re: Strategies based on Ehlers' work [Re: boatman] #446450
10/15/14 22:03
10/15/14 22:03
Joined: Oct 2014
Posts: 42
DEVON
S
scotpip Offline
Newbie
scotpip  Offline
Newbie
S

Joined: Oct 2014
Posts: 42
DEVON
Hi boatman

Glad you found the video worth watching.

The latest version of MESA is MESA9l, I think. You can get the suite for Tradestation, eSignal and NeuroShell. I wonder if he'd sell a dll for more general use?

http://www.mesasoftware.com/mesa.htm

I'd imagine the MESA9 formulae are still proprietary. My gut feel is that the general principles will be more important than the latest tweaks, but it would be nice to have the latest version that's openly published. I'm waiting for the new book on inter-library loan. I understand there's a fair bit of EasyLanguage code in there. Is there an updated MESA?

I won't be able to follow the maths, but the reviews suggest you can still pick up a lot from it. Do you have the background to understand the detail?

Thanks for the heads-up on DdIV's post. Pretty impressive result, for a 24 hour candle traded on a slow instrument without filters or stops! Most hedge funds would kill for a return like that... And all in 14 lines of code, including charting and logging. You've got to love Zorro!

I'm going to have a little play with DdIV's strategy and your EBS indicator...


Last edited by scotpip; 10/15/14 22:08.
Re: Strategies based on Ehlers' work [Re: scotpip] #446453
10/16/14 04:09
10/16/14 04:09
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Hey scotpip

I had a look a the mesa software website, and it seems that some of those indicators are discussed in the latest book, but not all of them. He talks about different methods for analysing spectra, plus you get the code for the detrender and instantaneous trendline (he calls it a 'decycler').

If you do want to gain a good understanding, my advice is don't be put off by the maths. I have an engineering and science background, so it wasn't foreign to me. But I can also say honestly that it is not as high powered as it might seem. You only really need to get your head around the basics of complex numbers, differential calculus and trigonometry to follow Ehlers' methodologies. Also it helps to be familiar with the fundamental characteristics of waves (amplitude, period, frequency, phase etc). There are online tutorials that would get you up to speed in a few days to a week. I think its well worth it.

Also, I'd be more than happy to try to answer any questions about Ehlers' methods. It would help my own understanding as well.

Cheers

Re: Strategies based on Ehlers' work [Re: boatman] #446458
10/16/14 09:53
10/16/14 09:53
Joined: Oct 2014
Posts: 42
DEVON
S
scotpip Offline
Newbie
scotpip  Offline
Newbie
S

Joined: Oct 2014
Posts: 42
DEVON
Well, if you ever get the chance to code any of them up, it would great to try them. I might give it a go myself once I'm a bit more fluent with Lite-C and Easy Language.

Long time since I've done any serious math (apart from stats), but with your encouragement I'll give it a try. I've got some calc and trig but I'd have to bone up on number theory. The signal processing concepts I've grokked on the web - not too scary.

I may well take up your offer to help if I get stuck. As you say, teaching someone is often a good way to clarify your own thoughts.

How are you finding his indicators in terms of practical strategy development? Any promising results?

Re: Strategies based on Ehlers' work [Re: scotpip] #446462
10/16/14 11:34
10/16/14 11:34
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Yeah, definitely some promising results. I've been playing around with the Even Better Sine Wave indicator as the basis of a system. It has some potential I think, particularly in catching and sticking with a trend. Here's a description of the system:

Buy when the EBSW crosses over some lower threshold from below.
Sell when the EBSW crosses under some upper threshold from above.
Exit if the super-smoother filtered price crosses the 'decycler' or instantaneous trendline.

Here's the code:

Code:
// =====EHLERS' EVEN BETTER SINEWAVE SYSTEM=====

function run()
{
set(PARAMETERS+TICKS);
NumSampleCycles = 6; 

//High pass filter cyclic components whose periods are shorter than duration input
vars Price = series(price());
vars SmoothPrice = series(Smooth(Price, 10));
var Duration = optimize(40, 20, 70); //max length of trend trade
vars HP = series(HighPass1(Price, Duration));
plot("SmoothPrice", SmoothPrice, 0, ORANGE);

//Smooth with super smoother
vars Filter = series(Smooth(HP, 10));

//3-bar average of wave amplitude and power
vars Wave = series((Filter[0] + Filter[1] + Filter[2])/3);
vars Pwr = series((Filter[0]*Filter[0] + Filter[1]*Filter[1] + Filter[2]*Filter[2])/3);

//Normalize average wave amplitude to square root of the average power
vars ebsw = series(Wave[0]/sqrt(Pwr[0]));

////Decycler
var HPCutoff = optimize(40, 10, 60, 5);
vars HP = series(HighPass(SmoothPrice, HPCutoff));
vars Decycler = series(SmoothPrice[0] - HP[0]);
plot("Decycler", Decycler, 0, BLUE);

//Trade paramters
var threshold = optimize(0.8, 0.7, 0.95, 0.025);
vars Signals = series(0);

Stop = 4*ATR(20);

if (crossOver(ebsw, -threshold)) 
	enterLong();
if (crossUnder(ebsw, threshold)) 
	enterShort();
	
if (crossUnder(SmoothPrice, Decycler))
	exitLong();
if (crossOver(SmoothPrice, Decycler))
	exitShort();

plot("ebsw", ebsw, NEW, RED);
plot("up", threshold, 0, BLACK);
plot("down", -threshold, 0, BLACK);

}



Optimised performance on EUR/USD attached. As you can see, not tradeable in its current form, but it does give some timely trend trade signals. Notice that the losing periods are generally when the market is going sideways, or cycling. To me this suggests that somehow filtering these sideways periods could improve performance considerably.

What do you think? Any ideas?

Attached Files EBSW.png
Re: Strategies based on Ehlers' work [Re: boatman] #446471
10/16/14 16:16
10/16/14 16:16
Joined: Oct 2014
Posts: 42
DEVON
S
scotpip Offline
Newbie
scotpip  Offline
Newbie
S

Joined: Oct 2014
Posts: 42
DEVON
Hi

Thanks for posting. No time today, but will play tomorrow.

With old-style indicators I've found that ADX is pretty good at keeping you out of the rough stuff - varies by instrument but under 20-25 or very low and falling are usually signs you don't want to be trading. Nothing new, but I do find it works well.

In the attachment these two rules do a pretty good job of filtering out the nasty signals (red lines) and leaving in the wins(green) (GBPUSD). Not cherry picked - simply the start of chart.

I'm hoping that there's an Ehlers momentum indicator that will be a step forwards, though? Anything you think is worth looking at?

Attached Files Ehler ADX filter.png
Page 1 of 2 1 2

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1