Results 1 to 3 of 33

Thread: How to solve ZERO DIVIDE issue in MT4?

  1. #1
    How can I approach the inverse for currency prices and have them saved in an array?

    For example: EURUSD = 1.1050 means USD/EUR = .9049

    on a simple calculator we just take 1/1.1050 which doesn't appear to work so nicely in arrays

    Lets state

    P1 = 1/iClose(NULL,0,n 1);
    Buffer1 = P1;

    with all the code above I get a zero divide issue,
    however when I just use 1/iClose(NULL,0,1); instead without adding to the array worth, it computes the appropriate calculation.

    How can I get these to work for saved values?

  2. #2
    Quote Originally Posted by ;
    Before performing your calculation, check when the divisor is equal to 0. if(divisor ! = 0)...
    Due I did that for ALL the calcs within the loop and it functioned, it had been picking up 0 info from nonexistent bars in the past. Works fine. Thank you.

    I used

    if (VAR gt; 0) VAR = 1/VAR;

  3. #3
    Before doing your calculation, assess if the divisor is equal to 0.

    Inserted Code if(divisor ! = 0) ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.