Division zero error

Forums ProRealTime English forum ProOrder support Division zero error

Viewing 15 posts - 1 through 15 (of 35 total)
  • #212306

    Hi,

    My systems stops with this error “The trading system was stopped due to a division by zero in one of its sub-functions during the evaluation of the last candlestick. You can add protections to your code to prevent divisions by 0 then backtest the system to check the correction.”

    Backtest also looks fine.

    Nothing is divided by zero. Can it be something else?

    #212307

    You have to check any value that are used in each of the division. Do you have some? In the backtest or in indicators that are called?

    #212315

    I have checked all values in each division noone is 0. I call for all the indicators.

    I run the algo wihtout calling the indicators and that works fine. But the other version when i Call each indicator with exact same numbers I get the error. Even though backtests are exact same.

    There is one tiny different, which I dont think matters? The one wihtout calling has DEFPARAM preloadbars = 5000 and the calling one has DEFPARAM preloadbars = 10000

    #212394

    There are many reasons why a division by zero can occur, in order to be more precise I need to get into the code 🙂

    #212421

    But how come the error only occurs on the system with call function?

    #212422

    ”sub-functions during the evaluation of the last candlestick.”

     

    What does sub-functions mean? Does it refer to indicator, trailing stop, preloadbars or something else? As I mentioned none of the divisions are 0.

    #212473

    As I mentioned none of the divisions are 0.

    Franro, You won’t know that because internally all sorts of other commands are executed (think like 10 commands get in place of one command you wrote). So it requires imagination of what is implied.

    I would say that a sub function is something you would explicitly Call. But you are correct in thinking that it could be anything. PRT development likes to give their own “names” to existing phenomena. But also think of the translation to English. In French it could have been “Sub Routines”. That is a normally existing phenomenon and now it will be about some routine you call indeed. Can be an indicator – can be any code you have written/gotten in .itf form – and call.

    If you are not going to show the code and also the code(s) of what is called, then here it stops. Even with code these things are some times tough to solve or work around.


    It is not a bad idea to think that this could be a PRT bug. But in any event, take care that you have sufficient DefParam PreLoadBars pre-loaded. For this, observe all your functions like Average and all, and envision how many bars they would require to do their work in full.

    1 user thanked author for this post.
    #212505

    If you are using Volumes or try to make division during calm hours, then a lack of values could be the cause..

    #212507

    Alright thanks guys. One more question, if I have the EXACT same algo running wihtout call functions and one with call function. Can the call function strategy get repeatidly errors and the other one dont, even though all indicator is the same? Both show same backtest. And both ran on demo accounts on different accounts.

    #212522

    A track with the CALL is to use fixed rather than variable parameters in your call, i.e. the indicator must not have external parameters, if it is possible to do so opposite your strategy, I suggest you give it a try. If you don't want to share the code on the forum, it is possible to create a support ticket that could go deeper and find a solution to your problem.

    1 user thanked author for this post.
    #212724

    Ok, I fixed the differnce between the 2 codes but now the problem still ocurred on both = division 0. If backtest does not show the problem, how could I even try this?

    #212725

    Should I just put .0001 on every other variable and try to find it this way (will take weeks). Or is there another way to solve this on my own?

    #212726

    Im not sure but maybe below occur division 0? But how can I try this and be sure?

    #212734

    Try adding this line of code at end of your code and check – after backtest – if value was ever 0?

     

     

     

    1 user thanked author for this post.
    #212735

    Thanks Grahal! Will do it now with realcode and find the issue.

Viewing 15 posts - 1 through 15 (of 35 total)

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