NexusFi: Find Your Edge


Home Menu

 





Floating point invalid operation?


Discussion in MultiCharts

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




 
Search this Thread
  #1 (permalink)
 hughesfleming 
Sliema+Sliema/Malta
 
Experience: None
Platform: Multicharts, Proprietary
Broker: IB,IQFeed,Barcharts.com
Trading: Stocks,Futures
Posts: 41 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?
Iran Airspace Collapses 18 Points to 15.5% While Hormuz …
Prediction Markets & Event Contracts
MegaETH Proves the Crowd Right: Prediction Markets Calle …
Prediction Markets & Event Contracts
Hormuz Normalization Collapses to 19.5% -- Iran Regime F …
Prediction Markets & Event Contracts
Iran Update May 8: Still Reviewing MOU, Demands Reparati …
Traders Hideout
SEC Chairman Calls for New Golden Age of SEC-CFTC Regula …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
The Pivot Point 113.6³ — Navigating the Prediction of …
26 thanks
Sober Journey With S&P
17 thanks
The Confluence Meter: A Multi-Layered Signal Framework B …
11 thanks
NT8 color choices
10 thanks
Volume Indicators
7 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639

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 X Reply With Quote
  #3 (permalink)
 hughesfleming 
Sliema+Sliema/Malta
 
Experience: None
Platform: Multicharts, Proprietary
Broker: IB,IQFeed,Barcharts.com
Trading: Stocks,Futures
Posts: 41 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,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639

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 X Reply With Quote
Thanked by:




Last Updated on June 15, 2017


© 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