Login Page - Create Account

Support Board


Date/Time: Thu, 16 Jan 2025 13:15:28 +0000



[User Discussion] - Ehlers Roofing filter

View Count: 2642

[2014-12-22 22:13:31]
ehlaban - Posts: 50
From TASC Magazine Jan 2014.

Ganz has also uploaded a version. Thanks Ganz i learned a lot from your code!
[usr dscssn] Roofing filter study


attachmentehlEhlersRoofingFilter.cpp - Attached On 2014-12-22 22:12:30 UTC - Size: 2.79 KB - 533 views
attachmentehlEhlersRoofingFilter.dll - Attached On 2014-12-22 22:12:43 UTC - Size: 16.5 KB - 505 views
[2017-06-21 13:41:56]
michelh - Posts: 159
thanks ehlaban,

just a quick question - I know that your code is correct but i have a question about coding concepts.


his definition of alpha (TS code) is:

alpha1 = (Cosine(.707*360 / HPPeriod) + Sine (.707*360 /
HPPeriod) - 1) / Cosine(.707*360 / HPPeriod);

Your code reads:
float tr, fi;
    tr = 360 * 3.14159f / 180;
    fi = 0.707f * tr / Bars.GetInt();
    alpha1 = (cos(fi) + sin(fi) - 1) / cos(fi);

so you have introduced an extra factor of 2 pi into the sin/cos in defining alpha.
Why did you have to do this?
And why didn't you write tr = 2 * 3.14f? why did you do the 360/180?


When I coded it myself, I got nothing but gibberish in the output. But if you have 2 minutes to write me a note to tell me why you had to do it like this, that would be appreciated.

Many thanks,

Michel
[2017-06-21 18:03:14]
ehlaban - Posts: 50
Mmm, that's a long time ago. I think it has to do with the conversion from radians to degrees

https://stackoverflow.com/questions/135909/what-is-the-method-for-converting-radians-to-degrees
https://gist.github.com/dbrockman/4773781
http://www.cplusplus.com/forum/beginner/197655/
[2017-11-09 18:01:55]
Jezz - Posts: 33
One Time Calculations That Do Not Run During Study Updating

Just watching the code, I realized that filter coefficients are calculated every updating time. Filter coefficients need to be calculated just once from the period parameter.

example from the supersmoother section

a1 = exp((-1.414f) * 3.14159f / LPPeriod.GetInt());
b1 = 2 * a1 * cos(1.414f * (180 * 3.14159f / 180) / LPPeriod.GetInt());
c2 = b1;
c3 = (-1)*a1*a1;
c1 = 1 - c2 - c3;

All these values depends only on LPPeriod, so they need to be calculated once after the "period" parameter change is applied.

I've tried to move this portion of code to a if section as suggested in ACSIL Programming Concepts: One Time Calculations That Do Not Run During Study Updating without any success. If I try to change the value of period, it doesn't look to affect.

if(sc.Index == 0)
{
//Code to run only on study full recalculation
....
}

Is this the right approach?
Any suggestion welcome

Thanks

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account