Division zero error

Viewing 15 posts - 16 through 30 (of 35 total)
  • Author
    Posts
  • #212736 quote
    deleted23092025
    Participant
    New

    I checked every division in the code by graphing it. None is 0

    some things pending between 0,005 and 1 but nothing is 0

    #212745 quote
    GraHal
    Participant
    Master

    Over how many bars is that you are checking for 0’s?

    #212754 quote
    deleted23092025
    Participant
    New

    As it happend most recently 30th march I checked with bars only covering that trade. But Maybe I did not check the division for that only backtest. And I also checked different variations of bars to remove the options its not preloadbars.

    But I guess i should do the same for all division and check if they act different (Become 0) if the barset is different.

    I will check that tomorrow and get back here again. Thanks again!

    #212763 quote
    GraHal
    Participant
    Master

    An easier way – over for example 10K bars – would be to use …

    GRAPH (MaxRSI-MinRSI) <= 0

    Then you should see a 1 when above is True.

    thanked this post
    #212765 quote
    deleted23092025
    Participant
    New

    Thanks alot mate!

    #212767 quote
    GraHal
    Participant
    Master

    If above doesn’t work, try …

    Div0 = (MaxRSI-MinRSI) <= 0
    GRAPH Div0
    #212781 quote
    deleted23092025
    Participant
    New

    It is so wierd, the system stopped again today and I got the same message. When I backtest 200 units and check order list the trade is not there.

    #212782 quote
    deleted23092025
    Participant
    New

    StochRSI = (myRSIMinRSI) / (MaxRSIMinRSI)

    Should I just not.. Graph stochRSI <= 0  ?

    Because “(myRSIMinRSI)” can also be 0?

    Well none of that works. I will just graph StochRSI and all the other division but still 0. I am getting nuts on this haha

    #212783 quote
    deleted23092025
    Participant
    New

    Also I get nothing under in my orderlist under “cancelled/Rejected”

    #212784 quote
    deleted23092025
    Participant
    New

    I have been running this system wihtout any problems for 3 years. I just tweaked some numbers and changed the trailingstop

     

    So as I thought it be some kind of preload bars thing as I have ran the system for long time in demo I tried backtesting with only the recent trade fitting (meaning bascily 0 preload bars) the trade still shows up. This means preloadbars is not the issue.

    I checked all the division none is 0. I checked if trialingstop somehow is below minimum no problem there also. I went through the code several times just to think of what it can be.

    #212786 quote
    GraHal
    Participant
    Master

    Try this …

    StochRSI = (myRSI–MinRSI) / max(1,(MaxRSI–MinRSI))
    #212787 quote
    deleted23092025
    Participant
    New

    I looked arround the forum for the same problem.. And I found this part

    “x = std[Period](close)
    if x=0 then
    x=1
    endif”

    which means I can do it on every divison to secure 0 not to come again. In this scenario I can just

    “if StochRSI = 0 then

    x=1

    endif”
    Right?

    #212788 quote
    deleted23092025
    Participant
    New

    Hmm and also I use ODD numbers in Period in my code so I think that might be causing the errors I am not sure yet

    #212790 quote
    deleted23092025
    Participant
    New

    I saw @robertgozzi write this

    “Check that all periods within brackets have a “normal” period number, such as 10, 20, 200 or 500 and not 10000 or 15000!

    This may happen if some period numbers are not simple constants but are the result of an expression, or use BARINDEX or the like incorrectly.”

    Means in my case 3 would cause a problem division 0 error?

    #212792 quote
    GraHal
    Participant
    Master

    and not 10000 or 15000!

    Robert said above because the max number of preload bars is 10000 and so any period >= 10000 would likely bring problems.

    3 would cause a problem division 0 error?

    Not in itself no, 3 can be fine, 3 can cause problems, but not because it is a value = 3.

    Re your div0 Rejection … try my max(1,??) suggestion I posted above … this is the one fix that works for me when I get div0 Rejections.

    thanked this post
Viewing 15 posts - 16 through 30 (of 35 total)
  • You must be logged in to reply to this topic.

Division zero error


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 34 replies,
has 4 voices, and was last updated by GraHal
2 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/28/2023
Status: Active
Attachments: No files
Logo Logo
Loading...