Divide by Zero issues

Forums ProRealTime English forum ProOrder support Divide by Zero issues

Viewing 7 posts - 1 through 7 (of 7 total)
  • #153652

    Hi

    My system is stopping every Sunday night at 2305 without fail. It works the rest of the week. The reason if gives me is more or less a divide by zero error. I believe the reason is because there is not sufficent data (previous bars) in order for me to make the required calculation.

    The code I am using is along the lines of

    Gap = Close-CustomClose[1]

    IF <indicator> and GAP <= 21 THEN

    Etc etc

     

    I believe at certain times Gap is not able to return a value so the system fails. Is there a way to code around this? something along the lines of:

     

    If Gap = Null/Error then do nothing Else carry on etc?

    Hope this makes sense as I kind of new to ccoding.

     

    thanks!

    #153657

    Try …

     

    1 user thanked author for this post.
    #153658

    You can try this to make sure it’s never 0:

    this small amount shouldn’t affect your performance (but you can increase or decrease it).

    You can also write it as:

     

    1 user thanked author for this post.
    #153659

    @GraHal

    that works with positive numbers, but in this case the gap can be negative and your code could change it quite a bit!

     

    2 users thanked author for this post.
    #153663

    Doh!, yes, that seems so intuitive and obvious (now I see it!).

    Thank you so very much, I will try these out.

    #153664

    now I see it!).

    Must have been that monobrow obstructing your vision! 🙂  (sorry couldn’t resist! 🙂 )

    1 user thanked author for this post.
    #153677

    now I see it!).

    Must have been that monobrow obstructing your vision! 🙂 (sorry couldn’t resist! 🙂 )

    Haha, I guess i deserved that! 😬

    1 user thanked author for this post.
Viewing 7 posts - 1 through 7 (of 7 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login