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 Fu510n with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 5,423 views
    2. thumb_up 4 thanks given
    3. group 5 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread
  #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?
Iran Update May 8: Still Reviewing MOU, Demands Reparati …
Traders Hideout
ATFX Suspends Prop Trading Unit ATFunded -- Full Review …
Funded Trading Evaluation Firms
Election Sunday Resolves: Peru Heads to Runoff at 42pct, …
Prediction Markets & Event Contracts
Powell in 48 Hours: Word Markets Give 78% on Inflation, …
Prediction Markets & Event Contracts
UMA Votes Tonight: Polymarkets $80M Strategy Bitcoin Bat …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
196 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
BERN ALGOS algo trading journal
8 thanks
Volume Indicators
8 thanks
  #3 (permalink)
 
Fu510n's Avatar
 Fu510n 
Suffield, CT
 
Experience: Advanced
Platform: TS, MC, MW, Python, Rust
Broker: TS, IB, IQFeed, Kraken
Trading: NQ, ES, CL, RTY
Frequency: Several times daily
Duration: Seconds
Posts: 165 since Oct 2009
Thanks Given: 943
Thanks Received: 166


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 X 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 Stellar & Tradestation
Broker: Primarily Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals, U308 and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,241 since Dec 2013
Thanks Given: 4,585
Thanks Received: 10,531

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,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

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 X 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,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

@davidcolin,

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

Regards,

ABCTG


Follow me on X 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


© 2026 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 - Downloads - Top
no new posts