Division by zero error

Viewing 4 posts - 16 through 19 (of 19 total)
  • Author
    Posts
  • #74947 quote
    Daniel_H
    Participant
    Senior

    I will check out your code later today when I continue to program.

    To answer your first question why I multiplied by ten it was because of Nicolas answer earlier in this thread, I dont know if he’s wrong, here’s his answer:

    “Only do division if the divisor variable is superior to 0, it usually avoid this kind of error”.

    So he’s not talking about the result, but the divisor.

    And about my last piece of code I described why I did it. Just to prove that the divisions works fine even if the results are zero something if you use them the next candle instead of the current one, so the problem is that PRT doesn’t do anything until the very end of each candle. Is there a way to contact the developers directly regarding this?

    #74949 quote
    Vonasi
    Moderator
    Master

    Only do division if the divisor variable is superior to 0, it usually avoid this kind of error

    I believe that what Nicolas means by this is check the values first.

    If a <> 0 and b <> 0 then
    c = a / b
    endif

    Your last bit of code changed nothing – it just looked at a different candle so the values were different so the results were different. There will still have been the possibility of division by zero.

    Daniel_H thanked this post
    #74950 quote
    Vonasi
    Moderator
    Master

    so the problem is that PRT doesn’t do anything until the very end of each candle. Is there a way to contact the developers directly regarding this?

    This is not the problem and anyway MTF will be introduced to PRT later this year meaning that you will be able to make decisions mid candle based on different time frames – so asking PRT to change this and make everyone’s already coded strategies obsolete is likely to be a wasted effort. If you do still want to ask them then I would suggest posting something in the Support forum that is monitored by PRT.

    ProRealTime platform support

    Daniel_H thanked this post
    #74962 quote
    Daniel_H
    Participant
    Senior

    Hi again Vonasi.

    Thanks for the solution

    bearcandlesize = max((open - close), 0.000000001)
    bearwicksize = max((close - low), 0.000000001)
    bearcandlevswick = bearcandlesize / bearwicksize

    it seems to work (I don’t lose trades anymore), now I have to figure out/understand what the calculations are doing because I don’t only want solutions, I want to understand what’s happening too. But I figure it out, just don’t have time right now.

    About Nicolas I guess I understood it wrong then, because in division you have: dividend/divisor = result, so when he wrote divisor I thought the problem lied in that part of the division only, thanks for the check of that part. Even though that wouldn’t work with all trades that would include zero values, but your solution using the max-function above solves it in my code.

    Ok good about the multitimeframe part, I guess it might be best to wait for it first and check the difference then.

    /Daniel

Viewing 4 posts - 16 through 19 (of 19 total)
  • You must be logged in to reply to this topic.

Division by zero error


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
kem2709 @kem2709 Participant
Summary

This topic contains 18 replies,
has 6 voices, and was last updated by Daniel_H
7 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/10/2018
Status: Active
Attachments: No files
Logo Logo
Loading...