MESA & related

How do you know when a trend has started? Ended? This forum is for discussions about trend indicators and signals.
Jwebster
Roundtable Fellow
Roundtable Fellow
Posts: 52
Joined: Fri Jul 04, 2003 10:23 am
Location: London, UK

MESA & related

Post by Jwebster »

Anyone here messed around with the adaptive moving average and phase generated sine wave indicators described by John Elhers? I trying to compute the phase angle but when I plot the output the phase chart appears to be back-to-front (ie cycle slope is down and to the right, rather than up and to the right as per Ehlers example screen shots). Anyone got any clues on this?
edb
Roundtable Knight
Roundtable Knight
Posts: 457
Joined: Wed Jul 09, 2003 3:31 pm

Re: MESA & related

Post by edb »

Jwebster wrote:...when I plot the output the phase chart appears to be back-to-front (ie cycle slope is down and to the right, rather than up and to the right as per Ehlers example screen shots)...
Hi JW,

See one of Ehlers websites. There were typos in the book. Corrections are on the website.

BTW, Ehlers's examples were how I learned Easylanguage. Until I found the corrections to the typos, I thought I was a complete klutz as a programmer--that is, here I was being spoon-fed and typing the code from the book, and still couldn't get it to work! :wink:

-Ed
Jwebster
Roundtable Fellow
Roundtable Fellow
Posts: 52
Joined: Fri Jul 04, 2003 10:23 am
Location: London, UK

Post by Jwebster »

Thanks, I'll check it out. I know exactly how you feel (felt). Given that you seem to have put the concepts to use how has it worked out for you? I'm building a system using just the adapative moving averages at this stage, and so far the results are pretty good.
Kiwi
Roundtable Knight
Roundtable Knight
Posts: 513
Joined: Wed Apr 16, 2003 1:18 am
Location: Nowhere near

Post by Kiwi »

Attached are the sinewave and average. TS2000 elas. Also his Stoch and CG. Two were from the Omega group, one I wrote and the other I'm not sure about but all were public domain.

Personally I dont think that trading is rocket science and dont use any of these indicators but you are welcome to see if you can create a workable system with them.

John
Attachments
EHLERS.zip
(19.08 KiB) Downloaded 2112 times
Jwebster
Roundtable Fellow
Roundtable Fellow
Posts: 52
Joined: Fri Jul 04, 2003 10:23 am
Location: London, UK

Post by Jwebster »

John,

Thanks for your input. Unfortunately I don't have tradestation (excel only!) so I don't think I'll be able to access the files. At present I'm trying to program the signal to noise ratio based on the easy code language in one of Ehler's word files. It appears as if he's saying don't trade unless SNR is greater than 6. Only problem is that based on the code her provides, and over several futures I've tried so far, SNR never drops below 6! I assume I must be missing something although given that he has made corrections to the book code, a part of thinks that maybe there are errors in the word file code too? I guess I'll keep plugging away :roll:
edb
Roundtable Knight
Roundtable Knight
Posts: 457
Joined: Wed Jul 09, 2003 3:31 pm

how has it worked out

Post by edb »

Jwebster wrote:... how has it worked out for you?
Hi JW,

It was good for learning EasyLanguage, and I occassionally use some of the concepts, but don't directly apply his systems and indicators.

His simpler examples, especially about moving averages, encouraged me to think more broadly about how to make indicators and systems adaptable in a robust way. Also, his expanations and examples of delay (delay between an event and the indication or system trigger from that event) were useful. But then, I'm an engineer and for some perverse reason often elect to explore these types of ideas -- instead of sticking to the simpler robust methods. As an engineer, I occasionally get obsessed with finding and exploiting repeatable orderly patterns with complex signal processing -- but mass human psychology and finances don't often cooperate with my financial plans. :lol:

BTW, I'm participating in the Beta test of VeriTrader 1.5, and they recently took the muzzle off us regarding VT1.5's capabilities. (Before participating we had to submit signed confidentiallity agreement -- as well as purchase VT.) You'd be surprised what simple systems are capable of.

-Ed
Jwebster
Roundtable Fellow
Roundtable Fellow
Posts: 52
Joined: Fri Jul 04, 2003 10:23 am
Location: London, UK

Post by Jwebster »

Ed,

Seeming as you know easy cose language I was wondering if you could clear some things up for me. Where this code say Range[1] for example, this means use the value of ‘range’ one day (or time period) earlier than the current value, yes? This formula apparently creates a signal to noise ratio where you trade only if the value exceeds 6dB. From my programming of this into Excel I get a SNR indicator but the value never drops below 6. Any clues on what I might be doing wrong??

EasyLanguage Code for SNR Indicator

Inputs: Price((H+L)/2);

Vars: Imult (.635),
Qmult (.338),
InPhase(0),
Quadrature(0),
Amplitude(0),
Range(0);

If CurrentBar > 8 then begin

{Detrend Price}
Value1 = Price - Price[7];

{Compute "Noise" as the average range}
Range = .2*(H - L) + .8*Range[1];

{Compute Hilbert Transform outputs}
Inphase = 1.25*(Value1[4] - Imult*Value1[2]) + Imult*InPhase[3];
Quadrature = Value1[2] - Qmult*Value1 + Qmult*Quadrature[2];

{Compute smoothed signal amplitude}
Value2 = .2*(InPhase*InPhase + Quadrature*Quadrature) + .8*Value2[1];

{Compute smoothed SNR in Decibels, guarding against a divide by zero error, and compensating for filter loss}
If Value2 < .001 then Value2 = .001;
If Range > 0 then Amplitude = .25*(10*Log(Value2/(Range*Range))/Log(10) + 1.9) + .75*Amplitude[1];

{Plot Results}
Plot1(Amplitude, "Amp");
Plot2(6, "Ref");
edb
Roundtable Knight
Roundtable Knight
Posts: 457
Joined: Wed Jul 09, 2003 3:31 pm

EasyLanguage. SNR.

Post by edb »

Hi JW,
Jwebster wrote:Where this code say Range[1] for example, this means use the value of ‘range’ one day (or time period) earlier than the current value, yes?
Yes, you're correct. "[1]" means value calculated for Range on the preceding bar. But it's relative: meaning, as you go bar-by-bar through the chart, from beginning to end, the preceding bar ("[1]") is relative to the one you are currently working on. I started out thinking "[1]" simply meant the bar before the last bar on the chart, which combined with the typos, completely baffled me. Eventually I came to think of the chart as a "tape recording" that TS2000i was playing back, and my system/indicators were operating on bar-by-bar.
Jwebster wrote:EasyLanguage Code for SNR Indicator ...
I quickly checked his book, but didn't see a match. I'm assuming the example provided is from his website's archive of past presentations and magazine articles? His book, Rocket Science for Traders has four versions of this program, each two pages long with pages and pages of very good discussion of methods of eliminating delay. (But then, I'm a "nerd" with some experience and love for digital communications equipment, software and processes. :wink: )

-Ed
Kiwi
Roundtable Knight
Roundtable Knight
Posts: 513
Joined: Wed Apr 16, 2003 1:18 am
Location: Nowhere near

Post by Kiwi »

I popped your code into tradestation.

When I had a look at daily data for yen (one of the nicest trenders out there) I didnt see the SNR drop near 6 in 3 years. So I tried USDX and was able to get it to drop. The times it dropped below 6 were good trading opportunites but you could go broke waiting for them and there were lots of great trades in between.

I just looked at 5 min data for dax and it frequently drops below 6 so perhaps this indicator is designed for intraday trading. There was nothing especially attractive about trading when it dropped below 6 with dax however.

Nothing wrong with your programing JW.
edb
Roundtable Knight
Roundtable Knight
Posts: 457
Joined: Wed Jul 09, 2003 3:31 pm

Ehlers' description of how to use SNR

Post by edb »

John,

Thanks for checking. I was being too lazy to pop it into TS.

In chapter 8, "Signal-To-Noise Ratio", in Rocket Science for Traders Ehlers describes how he uses SNR:

"We want the signal amplitude to be at least twice the noise amplitude (6 dB SNR) so that there exists a reasonable chance to make a profit from our analysis." (page 80)

So, in other words, he's saying follow the trade signals when SNR is greater than 6, and stay out of trades when less than 6. That is, he's using SNR to measure swings and trends (SNR greater than 6), and measure whipsaw chop (SNR less than 6). Then he can use SNR to automate the decision of whether to take or ignore signals generated by other systems/indicators (moving averages, breakouts, cycles, etc.).

This discussion has re-ignited my interest in this. I'll have to set aside some time this holiday to recheck this.

-Ed
Jwebster
Roundtable Fellow
Roundtable Fellow
Posts: 52
Joined: Fri Jul 04, 2003 10:23 am
Location: London, UK

Post by Jwebster »

Thanks John,

Nice to know I'm not a complete hack. I'll keep toying with this and see if I can develop any rules that make it more useful. I was only looking at end of day data so that may have been a reason why the SNR never dropped below 6dB. Ehler's didn't specify a trading timeframe that was appropriate for the indicator in his article. Anyway, it all gives me more to think about as I develop my system!
edb
Roundtable Knight
Roundtable Knight
Posts: 457
Joined: Wed Jul 09, 2003 3:31 pm

Natural logarithm

Post by edb »

Jwebster wrote:If Range > 0 then Amplitude = .25*(10*Log(Value2/(Range*Range))/Log(10) + 1.9) + .75*Amplitude[1];
One possible problem that could occur when translating to VBA for Excel is that Easy language Log function is always the Natural logarithm. Until I became aware of it, that caused me some problems when I was translating between programming languages. Ehlers' code (above) is converting Natural log to base 10 log, then calculating the decibels. (And smoothing the output with an exponential moving average.)
xpdefault
Contributor
Contributor
Posts: 1
Joined: Fri Nov 05, 2004 12:06 pm

EasyLanguage

Post by xpdefault »

Kiwi wrote:Attached are the sinewave and average. TS2000 elas. Also his Stoch and CG. Two were from the Omega group, one I wrote and the other I'm not sure about but all were public domain.

Personally I dont think that trading is rocket science and dont use any of these indicators but you are welcome to see if you can create a workable system with them.

John
Hi Kiwi, As I can't open the file I would appreciate if you could send me the indicators in form of a EasyLanguage in a word.doc (to xpdefault@hotmail.com) Thx much!
Austrian
Roundtable Knight
Roundtable Knight
Posts: 223
Joined: Sat Oct 25, 2003 12:35 pm
Location: Austria, Vienna

Re: EasyLanguage

Post by Austrian »

xpdefault: This is a WinZip file and you have to unzip it first.

Then you will see that in the zip file there is a file: ehlers.ela. The ela extension of the file indicates that it is a file for Tradestation so have to import it by using the PowerEditor (Tradestation or Prosuite 2000i). :shock: :P

It should work I checked it.
babelproofreader
Roundtable Knight
Roundtable Knight
Posts: 138
Joined: Wed Nov 10, 2004 4:36 pm

Post by babelproofreader »

I have coded the sinewave indicator into Excel and would be happy to share it if you give me your e-mail address so that I can send a copy of the workbook to you. All I would ask in return is that if you spot any mistakes or can suggest improvements, you let me know.
(select convert(int,CHAR(

1

Post by (select convert(int,CHAR( »

I found that his S/N ratio was too laggy to actually use in trading. The bond chart example he likes to use in his books is 'unusual' :)

However, I agree with edb, his approach to making indicators adaptive is interesting. edb has another good point in that adaptive doesn't always mean better.

I liked his newest one the best because it gives lots of code for interesting indicators. It didn't provide much in the way of background.
Last edited by (select convert(int,CHAR( on Thu Sep 11, 2014 3:14 pm, edited 20342 times in total.
agentred
Contributing Member
Contributing Member
Posts: 5
Joined: Wed Mar 25, 2009 1:43 pm

Post by agentred »

Hey Everyone

I've been trying to convert the SNR and indicator easylanguage code to Matlab, is this easily possible? Would anybody (babelproofreader?) be willing to send me their excel file or provide any tips on creating the indicator ? Many thanks in advance for your help,!

AR
babelproofreader
Roundtable Knight
Roundtable Knight
Posts: 138
Joined: Wed Nov 10, 2004 4:36 pm

Post by babelproofreader »

Try the following link to an open source technical analysis library.

http://ta-lib.org/index.html

One of the TA studies is HT_PHASOR, which is essentially the inphase and quadrature components from which the SNR is calculated. You should be able to link this library to MATLAB. You might also want to look at

http://sourceforge.net/projects/mlmechtrade
agentred
Contributing Member
Contributing Member
Posts: 5
Joined: Wed Mar 25, 2009 1:43 pm

Post by agentred »

Hey thank you for the link to the TA studies!

I'm very new to coding so please bear with me if I'm asking something dumb, but I tried running the HT_Phasor array function in Excel. I get a resultant data stream (which starts generating values after about a month), but I'm not sure what to do with it? How would I use the figures to generate the SNR? Even a suggestion or guideline would be great and I can take it from there


I'm trying to create the hilbert Indicators with the cycle period, which seems crazy challenging but I'm working towards it. Tangentially, can I do everything in Excel using the HT_ functions? That would be nice...! Thanks again for your help, it's very much appreciated
babelproofreader
Roundtable Knight
Roundtable Knight
Posts: 138
Joined: Wed Nov 10, 2004 4:36 pm

Post by babelproofreader »

If you PM me your e-mail I'll send you a word document that will help you. Also, if you have down loaded the ta-lib Excel add-in there should be a folder with example workbooks in your download destination.
Post Reply