NexusFi: Find Your Edge


Home Menu

 





Kaufman Efficiency Ratio (error)


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one davidcolin with 4 posts (1 thanks)
    2. looks_two ABCTG with 2 posts (1 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 SMCJB with 1 posts (2 thanks)
    1. trending_up 3,886 views
    2. thumb_up 4 thanks given
    3. group 5 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread

Kaufman Efficiency Ratio (error)

  #1 (permalink)
davidcolin
Vancouver BC Canada
 
Posts: 7 since Dec 2014
Thanks Given: 5
Thanks Received: 2

Hi all,

just trying to code the Kaufman Efficiency Ratio in EasyLanguage as below (user function):

****************************************************

Inputs: length(numericsimple);

KaufmanER = absvalue( close - close[length] ) / absvalue( summation( (close - close[1]), length ) ) ;


****************************************************
Problem is I get a floating point invalid operation error when I apply this code. Can anyone help?

TIA!

David

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
How to apply profiles
Traders Hideout
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
18 thanks
  #3 (permalink)
 
Fu510n's Avatar
 Fu510n 
Suffield, CT
 
Experience: Advanced
Platform: MC, TS, Python, Rust
Broker: IB, IQFeed, TS, Kraken
Trading: ES, NQ, RTY, YM, CL, RB, 6E
Frequency: Several times daily
Duration: Seconds
Posts: 144 since Oct 2009
Thanks Given: 902
Thanks Received: 143


1) what are you passing in for length?
2) is/could the denominator be calculating as 0? (causing a divide by zero error; need to prevent that from happening if so)
3) have you taken a look at the Kaufman Efficiency Ratio indicator code in the D/L section?

Just a thought...

Follow me on Twitter Reply With Quote
  #4 (permalink)
davidcolin
Vancouver BC Canada
 
Posts: 7 since Dec 2014
Thanks Given: 5
Thanks Received: 2

Hi Fu510n....thanks for your response.

1. My coding ability is fairly rudimentary and as such I don't understand what "passing in for length" means. :/
2. Looks like it is a divide by zero error because I added the alternative:

Inputs: length(numericsimple);

If absvalue( summation( (close - close[1]), length ) ) <> 0
then KaufmanER = absvalue( close - close[length] ) / absvalue( summation( (close - close[1]), length ) )
else KaufmanER = 0

The floating point error disappears but the KER just plots as a straight line at 1. I didn't really know what to put for the alternative value....gah

3. I am not able to download that code as it for Elite members only, which I am not.




Fu510n View Post
1) what are you passing in for length?
2) is/could the denominator be calculating as 0? (causing a divide by zero error; need to prevent that from happening if so)
3) have you taken a look at the Kaufman Efficiency Ratio indicator code in the D/L section?

Just a thought...


Reply With Quote
  #5 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,049 since Dec 2013
Thanks Given: 4,386
Thanks Received: 10,206

absvalue(summation()) <> summation(absvalue())

This should work

Inputs: length(numericsimple);

If summation( absvalue( (close - close[1]), length ) ) <> 0
then KaufmanER = absvalue( close - close[length] ) / summation( absvalue( (close - close[1]), length ) )
else KaufmanER = 0

Reply With Quote
Thanked by:
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

davidcolin,

the solution @SMCJB provided should fix the error. In general you might want to add a similar check to every division you do within any EasyLanguage code, to ensure the divisor is not 0 (it's enough to trigger this error in case it's 0 once on the very first call).

Regards,

ABCTG


davidcolin View Post
Hi all,

just trying to code the Kaufman Efficiency Ratio in EasyLanguage as below (user function):

****************************************************

Inputs: length(numericsimple);

KaufmanER = absvalue( close - close[length] ) / absvalue( summation( (close - close[1]), length ) ) ;


****************************************************
Problem is I get a floating point invalid operation error when I apply this code. Can anyone help?

TIA!

David


Follow me on Twitter Reply With Quote
Thanked by:
  #7 (permalink)
davidcolin
Vancouver BC Canada
 
Posts: 7 since Dec 2014
Thanks Given: 5
Thanks Received: 2

Thanks very much you guys. Your kindness and expertise is appreciated. I will try this out later today.

Reply With Quote
  #8 (permalink)
davidcolin
Vancouver BC Canada
 
Posts: 7 since Dec 2014
Thanks Given: 5
Thanks Received: 2

Thank you again. Your revision worked.

Reply With Quote
Thanked by:
  #9 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

@davidcolin,

you are welcome, I am glad to hear that it works for you.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #10 (permalink)
Tamir58
Tel Aviv/Israel
 
Posts: 1 since Jul 2018
Thanks Given: 0
Thanks Received: 0


it should be as follows:

Total_abs_change = Summation(Absvalue(Close - Close[1]), Kaufman_ER_Length) * 100;
Value1 = Close - Close[Kaufman_ER_Length];
Kaufman_ER = Value1 / Total_abs_change * 100;

Reply With Quote




Last Updated on January 20, 2022


© 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