NexusFi: Find Your Edge


Home Menu

 





Hilbert sine wave indicator


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Zondor with 10 posts (58 thanks)
    2. looks_two cory with 8 posts (14 thanks)
    3. looks_3 ntsst3 with 7 posts (3 thanks)
    4. looks_4 noyss with 6 posts (2 thanks)
      Best Posters
    1. looks_one Fat Tails with 7 thanks per post
    2. looks_two Zondor with 5.8 thanks per post
    3. looks_3 vegasfoster with 4.5 thanks per post
    4. looks_4 cory with 1.8 thanks per post
    1. trending_up 82,161 views
    2. thumb_up 134 thanks given
    3. group 38 followers
    1. forum 77 posts
    2. attach_file 27 attachments




 
Search this Thread

Hilbert sine wave indicator

  #71 (permalink)
 
noyss's Avatar
 noyss 
Ibiza. Spain
 
Experience: Intermediate
Platform: MT4
Broker: Darwinex
Trading: EminiSP, Crude, Euro/Dolar, Bitcoin.
Posts: 76 since Jul 2012
Thanks Given: 121
Thanks Received: 32


Zondor View Post
They SHOULD, work exactly the same, unless the second one has coding errors.

[/URL]


Did you refer to the __Oscillator_HilbertSinewave?

As you can see, __Oscillator_HilbertSinewave doesn´t plot support and ressistance as good as your first one

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Deepmoney LLM
Elite Quantitative GenAI/LLM
Futures True Range Report
The Elite Circle
Exit Strategy
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
Battlestations: Show us your trading desks!
26 thanks
NexusFi site changelog and issues/problem reporting
25 thanks
The Program
17 thanks
  #72 (permalink)
 
Zondor's Avatar
 Zondor 
Portland Oregon, United States
 
Experience: Beginner
Platform: Ninjatrader®
Broker: CQG, Kinetick
Trading: Gameplay Klownbine® Trading of Globex
Posts: 1,333 since Jul 2009
Thanks Given: 1,246
Thanks Received: 2,731

Note that the version Cory posted and I updated seems to be based on the code in John Ehlers' book, Cybernetic Analysis for Stocks and Futures. There is what appears to be a different version in one of his other books, Rocket Science for Traders. That one had some very minor differences in the input smoothing but the only significant difference is that the Rocket Science version had some typos that were not corrected in the Sine Wave that was on the Ninjatrader forum.

The corrections to the Rocket Science version are here (the real and imaginary parts got interchanged): https://www.mesasoftware.com/bookcompanions.htm
 
Code
pages 98 and 102 and 116 and 120 & 121: the code should be corrected to be: 
....... RealPart = RealPart + Sine(360*count/DCPeriod)*(SmoothPrice[count]); 
....... ImagPart = ImagPart + Cosine(360*count/DCPeriod)*(SmoothPrice[count]); 
....... If AbsValue(ImagPart) > 0 then DCPhase = Arctangent(RealPart/ImagPart); 
....... If AbsValue(ImagPart) <= .001 then DCPhase = DCPhase + 90*Sign(RealPart):
So there really should be only one version of this indicator, as the Cybernetics Analysis and Rocket Science versions are the same animal, both based on the Hilbert Transform.

For test purposes I am adding code to various indicators to measure the actual backfill time to the millisecond. It appeared that drawing support and resistance lines (using DrawText method) on the price panel caused unacceptable performance issues, increasing the backfill time from a few milliseconds to ten or more seconds. The solution would be to use one indicator to plot the sine wave in an indicator panel, and another indicator to PLOT, not DRAW, the support and resistance lines in the price panel. In this case at least, the DrawText method seems to be a voracious resource hog. Harry @Fat Tails had already mentioned this, but the resource hit is not minor... it is a disaster.

To further confuse the issue, there is the new Even Better Sine Wave in the latest Ehlers book, Cycle Analytics for Traders.

@noyss, could you share the code for the TOS version, preferably as a text file?

"If we don't loosen up some money, this sucker is going down." -GW Bush, 2008
“Lack of proof that something is true does not prove that it is not true - when you want to believe.” -Humpty Dumpty, 2014
“The greatest shortcoming of the human race is our inability to understand the exponential function.”
Prof. Albert Bartlett
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #73 (permalink)
 
Zondor's Avatar
 Zondor 
Portland Oregon, United States
 
Experience: Beginner
Platform: Ninjatrader®
Broker: CQG, Kinetick
Trading: Gameplay Klownbine® Trading of Globex
Posts: 1,333 since Jul 2009
Thanks Given: 1,246
Thanks Received: 2,731


I fixed the version of the Sine Wave that was posted on the Ninjatrader forums.

The program logic flow was wrong. Now, for the first time, the Rocket Science version plots correctly. Now it is actually usable.

It really is essentially the same as the Cybernetics Analysis version except for additional input smoothing options which may not improve the usefulness of the results anyway.

The Cybernetics version is three years newer than the Rocket version.

I did NOT fix the ridiculously inefficient code that was MINDLESSLY copied from the books. After fixing that, another possibility is an MTF version that will work on a time frame other than that of the chart master instrument.

The time needed for the indicator to backfill the historical bars prints to the output window.




"If we don't loosen up some money, this sucker is going down." -GW Bush, 2008
“Lack of proof that something is true does not prove that it is not true - when you want to believe.” -Humpty Dumpty, 2014
“The greatest shortcoming of the human race is our inability to understand the exponential function.”
Prof. Albert Bartlett
Attached Files
Elite Membership required to download: _____NTForumSineWave.cs
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #74 (permalink)
 tortoise 
Boston, MA
 
Experience: Intermediate
Platform: MultiCharts, TradeStation, NinjaTrader, ThinkorSwim
Trading: ES
Posts: 26 since Jul 2011
Thanks Given: 16
Thanks Received: 13

I tried the EasyLanguage version of Ehler's "Even Better Sine Wave" indicator and I get a "floating point invalid operation" error message. I believe I have been faithful to the original. Any thoughts as to what I'm doing wrong here?



var:
alpha1(0), HP(0), a1(0),b1(0),c2(0),c3(0), Filt(0), c1(0), count(0), wave(0), pwr(0);


alpha1 = (1 - sine(360/40))/ cosine(360/40);
a1 = expvalue(-1.414*3.14159/10);
b1 = 2*a1*cosine(1.414*180/10);
c2 = b1;
c3 = -a1*a1;
c1 = 1 - c2 - c3;


//High pass filter cyclic components whose periods are shorter than duration input
HP = 0.5*(1 + alpha1)*(CLOSE - CLOSE[1]) + alpha1*HP[1];
//Smooth with a Super Smoother Filter
Filt = c1*(HP + HP[1])/2 + c2*Filt[1] + c3*Filt[2];
//3 Bar average of Wave amplitude and power
Wave = (Filt + Filt[1] + Filt[2])/3;
Pwr = (Filt*Filt + Filt[1]*Filt[1] + Filt[2]*Filt[1])/3;

//Normalize the Average Wave to Square Root of the Average Power
IF PWR <> 0 THEN
Wave = Wave/SquareRoot(Pwr);

PLOT1(WAVE);

Reply With Quote
  #75 (permalink)
 tortoise 
Boston, MA
 
Experience: Intermediate
Platform: MultiCharts, TradeStation, NinjaTrader, ThinkorSwim
Trading: ES
Posts: 26 since Jul 2011
Thanks Given: 16
Thanks Received: 13


tortoise View Post
I tried the EasyLanguage version of Ehler's "Even Better Sine Wave" indicator and I get a "floating point invalid operation" error message. I believe I have been faithful to the original. Any thoughts as to what I'm doing wrong here?



var:
alpha1(0), HP(0), a1(0),b1(0),c2(0),c3(0), Filt(0), c1(0), count(0), wave(0), pwr(0);


alpha1 = (1 - sine(360/40))/ cosine(360/40);
a1 = expvalue(-1.414*3.14159/10);
b1 = 2*a1*cosine(1.414*180/10);
c2 = b1;
c3 = -a1*a1;
c1 = 1 - c2 - c3;


//High pass filter cyclic components whose periods are shorter than duration input
HP = 0.5*(1 + alpha1)*(CLOSE - CLOSE[1]) + alpha1*HP[1];
//Smooth with a Super Smoother Filter
Filt = c1*(HP + HP[1])/2 + c2*Filt[1] + c3*Filt[2];
//3 Bar average of Wave amplitude and power
Wave = (Filt + Filt[1] + Filt[2])/3;
Pwr = (Filt*Filt + Filt[1]*Filt[1] + Filt[2]*Filt[1])/3;

//Normalize the Average Wave to Square Root of the Average Power
IF PWR <> 0 THEN
Wave = Wave/SquareRoot(Pwr);

PLOT1(WAVE);

Never mind. Fixed it.

Yikes, this is indicator really blows. Lol.

Reply With Quote
  #76 (permalink)
kfu000
SINGAPORE
 
Posts: 1 since Sep 2015
Thanks Given: 0
Thanks Received: 0

Hi Tortoise,

I am running into the same problem and been scratching my head off, how do you fixed the floating point issues?
Many thanks,

Reply With Quote
  #77 (permalink)
blackfriday
Frankfurt Germany
 
Posts: 5 since Apr 2014
Thanks Given: 0
Thanks Received: 3

Hi,

I am quite new to this forum and have stumbled upon this topic by pure accident, but maybe it would be useful for you to share my experiences.

I have only limited experiences in trading, but was fascinated by Ehlers approaches some years ago. About two years ago, I started working on the different versions of Ehlers Sinewave indicators, first using Excel, later up to now MT5. Beginning with the Homodyne from Rocket Science, the Deltaphase from one of his later books (can't remember the title right now) and the Better Sine Wave from one of his last books. Since I have been professionally involved in Fourier Analysis long years ago, I have even been able to develop my own sinewave indicators, using the same maximum entropy algorithm Ehlers is claiming to use in his Mesa indicators. My indicators include variable lookback periods and nice spectrum displays. (Unfortunately I can't post a screenshot due to the resitrictions of this forum for newbies...)

To my experience, all indicators of this type are working great in a stable cycle mode.... but only there. One of the reasons is, that they are lagging due to a lot of necessary smoothing and detrending. If I remember correctly, the Homodyne lags about 20 bars. The complex calculations all try to extract the period of the so called "Dominant Cycle" from the price data, which takes about 20 bars or more. So the output is an average DC valid during the past 20 bars. The assumption for trading (and plotting the support and resistance lines) is, that this DC will continue in the future.

Unfortunately, to my limited experience, in a lot of cases this assumption will fail.

So I would recommend the homodyne based sine wave indicator as a useful confirming signal, excellent during cycle modes, but be very careful during trend modes, esp. during downtrends. My attempt was to use it in an automated trading system, but I have not been able to be profitable so far. I have only very limited experience in trading, maybe I simply have not been able to find a currency pair with useful cycle modes or a successful combination with other indicators.

Reply With Quote
Thanked by:
  #78 (permalink)
blackfriday
Frankfurt Germany
 
Posts: 5 since Apr 2014
Thanks Given: 0
Thanks Received: 3


tortoise View Post
I tried the EasyLanguage version of Ehler's "Even Better Sine Wave" indicator and I get a "floating point invalid operation" error message. I believe I have been faithful to the original. Any thoughts as to what I'm doing wrong here?



var:
alpha1(0), HP(0), a1(0),b1(0),c2(0),c3(0), Filt(0), c1(0), count(0), wave(0), pwr(0);


alpha1 = (1 - sine(360/40))/ cosine(360/40);
a1 = expvalue(-1.414*3.14159/10);
b1 = 2*a1*cosine(1.414*180/10);
c2 = b1;
c3 = -a1*a1;
c1 = 1 - c2 - c3;


//High pass filter cyclic components whose periods are shorter than duration input
HP = 0.5*(1 + alpha1)*(CLOSE - CLOSE[1]) + alpha1*HP[1];
//Smooth with a Super Smoother Filter
Filt = c1*(HP + HP[1])/2 + c2*Filt[1] + c3*Filt[2];
//3 Bar average of Wave amplitude and power
Wave = (Filt + Filt[1] + Filt[2])/3;
Pwr = (Filt*Filt + Filt[1]*Filt[1] + Filt[2]*Filt[1])/3;

//Normalize the Average Wave to Square Root of the Average Power
IF PWR <> 0 THEN
Wave = Wave/SquareRoot(Pwr);

PLOT1(WAVE);


Try

HP = (1 - alpha1 / 2)*(CLOSE - CLOSE[1]) + alpha1*HP[1];

Reply With Quote
Thanked by:




Last Updated on November 20, 2015


© 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