John Ehlers Sinewave

John Ehlers Sinewave

This is an implementation of John Ehlers’ Sinewave Indicator, as described in Market Mode Strategies (1999-10-19).

This is a different and earlier version of the Sinewave Indicator, from what is described in John Ehlers’ books Rocket Science for Traders (2001-07-20) and Cybernetic Analysis for Stocks and Futures (2004-03-29). However, this is the most popular version of the algorithm and seems to achieve better results.

A more recent formula of Hilbert Transform, described in Squelch those Whipsaws (2000-24-03), can be used, by replacing the beginning of the code with:

The attached screenshot shows the Sinewave Indicator using original description (top) of and the alternative Hilbert Transform formula (bottom).

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

  1. cbeukes • 08/26/2018 #

    Very interesting indicator. Any advice on identifying the transition between ranging and trending markets?

    • Horance • 08/26/2018 #

      This is a good question. John Ehlers explains it in Rocket Science for Traders. You have to use the Sinewave Indicator in conjunction with the Instantaneous Trendline ( Basically, when the trendline crosses the Kalman filter, we start to count the number of bars. While the number of bars is inferior to half a period, we stay in cycle mode, otherwise we enter trend mode.

  2. cbeukes • 08/26/2018 #

    Much appreciated, I will give that a try. Also, is there any criteria that one could use to identify whether if a sinewave cycle cross is valid? Perhaps the level of an RSI or Stochastic using the cycle period as calculated above?

  3. avatar
    Anonymous • 08/26/2018 #

    Thanks for the code! I’m trying to understand how it works, and have a few questions… lines 16 & 17: howdoes InPhase[3] and Quadrature[2] have any values? Any indexes below 6 aren’t assigned. So, those values just return zero? Same with the Value3[4] array. What value does Value3[4] have from 4 bars ago? High? Low? Close? Nothing?

    Thank you 🙂

Register or


avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
Madrosat how do you use carnazzi filter in a strategy : smoothing , stop ,tendance
Bruno Carnazzi I have completely revised the mathematical foundations of this tool and offer you the finali...
Bruno Carnazzi Il me semble que la fonction "floor" n'est disponible qu'avec PRT11, à vérifier
DELBERT Bonjour , merci pour votre réponse , je m'excuse je suis avec PRT v10.3 donc c'est indicateu...
Nicolas c'est juste, c'est une instruction très récente.
RubberToe Is there something we are missing here, I just get the same curved line as well...
Khaled @Nicolas, Hi Nicolas, I've downloaded the itf and it doesn't display as an Oscillator, it"s ...
sal157011 I think the problem here is that you must feed the trigonometric functions cos and sin with ...
ggolfet Hi Actarus, what's the name of the histogram indicator below Apple's chart?
Actaru5 Flag ShowState in setting and show histogram
NicolaSilvagni hi, thank you for creating this indicator. i can't figure out how to get the three graphs b...
Nicolas Check your custom trading hours and use the default market ones.
fj_pastor Hello Nicolas, Thanks again for all your support. Finally I debugged the problem. The sim...
kallistos Hi Nicolas, Thank you very much indeed for this indicator (and all the others you are provi...
Morrissey38 Muchísimas gracias Nicolás , muy amable.
Bruno Carnazzi extrèmement pertinent
Bruno Carnazzi Is that beatable ?
Sapo Thank you for your indicators. As always it's perfect, I thank you for your help it's preci...
eivaremir have u got the trading view version?
carlvan That's a great indicator and I especially the use of colors, more or less pronounced to indi...
ALE Hello do you want to explain to me in more detail what you have to do? Please replay here:...
Nicolas Thanks again for all your valuable posts... and well formatted code! :)
Abdelkrim Maksour hi sir is this indicator for mt4 and how i can get one .
Nicolas Thanks a lot for this new valuable addition to our library. I changed line 76 with "barindex...
Horance Thanks. I've noticed this leftover after submission, but it was too late for editing. BTW, I...
Etienne Thanks Horance for porting this code to PRT. I would like to bring some speedup to your cod...
Bebbo Grazie del prezioso contributo Nicolas, scusa la mia inesperienza, sono alle prime armi e s...
Nicolas To avoid recalculation, you should use the one from this post.
Bebbo Ok Grazie Nicolas.
Appsoluxions Hi Nicolas, do you have the MT4 version of the indicator? I am not sure if these kind of que...
Nicolas Hi, don't have one sorry. But you can still ask for private coding through our programming s...
Appsoluxions Cool. Thanks for the response.