Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4064468
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:51:34+00:00 2026-05-20T15:51:34+00:00

I have downloaded a MetaTrader MQL4 language .mq4 source-code file from here and I

  • 0

I have downloaded a MetaTrader MQL4 language .mq4 source-code file from here and I think there is a divide by zero error contained in the file. The relevant section is:

                                   // Calculate sums for the least-squares method
n   = ( Taps - 1 ) / 2;

sx2 = ( 2*n + 1 ) / 3.0;

sx3 = n * ( n + 1 ) / 2.0;

sx4 = sx2 * ( 3*n*n + 3*n - 1 ) / 5.0;

sx5 = sx3 * ( 2*n*n + 2*n - 1) / 3.0;

sx6 = sx2 * ( 3*n*n*n*( n + 2 ) - 3*n + 1 ) / 7.0;

den = sx6 * sx4 / sx5 - sx5; // <---------------------------- a DIV!0 error here?

This demo-code case:

Am I correct in my assumption that there is an error in the code,
and if so,
perhaps someone could point out what the correction should be?


General computation cases:

What is the industry best-practice / what practical software-design measures ought be used as a life-jacket protection for DIV!0 incident(s)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:51:34+00:00Added an answer on May 20, 2026 at 3:51 pm

    A division by zero will occur if sx5 is zero. To find what would cause sx5 to be zero, solve sx5=0 for n.

    0 = sx5
    0 = sx3 * (2*n*n + 2*n - 1) / 3.0
    0 = (n*(n + 1) / 2.0) * (2*n*n + 2*n - 1) / 3.0
    ...
    0 = 2*n^4 + 4*n^3 + n^2 - n
    

    One possible solution to that equation is n=0, so a division by zero error will occur if Taps is 1. I don’t know if the equation has other solutions.

    Update: Added math.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have downloaded Orca to edit an MSI file. I want to remove some banner
I have downloaded the silver light from this http://www.microsoft.com/silverlight// I need to use this
I have a python application that relies on a file that is downloaded by
I have 2 SQLite databases, one downloaded from a server ( server.db ), and
I have downloaded php.vim file, which contains PHP-based syntax information. It should be able
I have downloaded a font that looks less than desirable if it is not
I have downloaded Privoxy few weeks ago and for the fun I was curious
Does anybody use the Class Designer much in Visual Studio? I have downloaded the
I'm new to Apex and have just downloaded Eclipse to get to work Eclipse
We have a number of PDFs hosted using Lighttpd but when they are downloaded

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.