NexusFi: Find Your Edge


Home Menu

 





Floating point invalid operation?


Discussion in MultiCharts

Updated
    1. trending_up 4,736 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread

Floating point invalid operation?

  #1 (permalink)
 hughesfleming 
Sliema+Sliema/Malta
 
Experience: None
Platform: Multicharts, Proprietary
Broker: IB,IQFeed,Barcharts.com
Trading: Stocks,Futures
Posts: 40 since Mar 2014
Thanks Given: 87
Thanks Received: 20

Hi,

I am trying to convert some code from mq4 to Easylanguage which uses a "better" Heiken Ashi close value. The following code gives me a floating point error and I am not sure why? It plots but when a new tick comes in it gives me the error. This is with RC 9.0

Thanks in advance,

Alex


 
Code
value1 = ((Open+Close) * 0.5) + ((Close-Open) / (High-Low)) * AbsValue((Close-Open) * 0.5);
Plot1 (value1,"BetterHaClose");

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
About a successful futures trader who didn´t know anyth …
Psychology and Money Management
Better Renko Gaps
The Elite Circle
Cheap historycal L1 data for stocks
Stocks and ETFs
REcommedations for programming help
Sierra Chart
MC PL editor upgrade
MultiCharts
 
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

hughesfleming,

you will run into this error when the study attempts to divide by 0. In your case when High and Low are the same your code will try to divide by zero. This produces the error message.
You can overcome this by adding a check like this and a good practice would be to set an alternative result in case High = Low.
 
Code
if (High-Low) <> 0 then
value1 = ((Open+Close) * 0.5) + ((Close-Open) / (High-Low)) * AbsValue((Close-Open) * 0.5)
else
value1 = your alternative in here
Regards,
ABCTG


hughesfleming View Post
Hi,

I am trying to convert some code from mq4 to Easylanguage which uses a "better" Heiken Ashi close value. The following code gives me a floating point error and I am not sure why? It plots but when a new tick comes in it gives me the error. This is with RC 9.0

Thanks in advance,

Alex


 
Code
value1 = ((Open+Close) * 0.5) + ((Close-Open) / (High-Low)) * AbsValue((Close-Open) * 0.5);
Plot1 (value1,"BetterHaClose");


Follow me on Twitter Reply With Quote
  #3 (permalink)
 hughesfleming 
Sliema+Sliema/Malta
 
Experience: None
Platform: Multicharts, Proprietary
Broker: IB,IQFeed,Barcharts.com
Trading: Stocks,Futures
Posts: 40 since Mar 2014
Thanks Given: 87
Thanks Received: 20


Super!

Kind regards,

Alex

Started this thread Reply With Quote
  #4 (permalink)
 olobay 
Montreal
 
Experience: Intermediate
Platform: MultiCharts
Broker: DeepDiscountTrading.com
Trading: CL
Posts: 364 since Jul 2011

I'm getting the same error message with this code:

 
Code
inputs: Length( 14 ), XMA_Avg(14);
variables: BMP( 0 );
BMP =  ( Close - Open ) / ( High - Low );
Plot1( Average( BMP, Length ) ) ;
Plot2( XAverage(plot1, XMA_Avg));
Plot3(0);
How can I fix this? Thanks in advance.

Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

olobay,

the solution is the same (your divisor is even the same, so you can use the same check) as described in #2 of this thread:

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on June 15, 2017


© 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