ADX causes 'divide by zero' error?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #136265 quote
    teapot2002
    Participant
    Average

    My code has been repeatedly stopping with ‘divide by zero’ errors. I have been reluctant to post it and ask for help as it contains someone else’s intellectual property, but after a lot of time I think that I’ve managed to isolate the lines causing the problem. I would very much appreciate help with why these cause a problem, and how to work round it. If I comment out the following lines then the code runs:

    ADXLongOK = ADX[6] > 5
    ADXShortOK = ADX[1.3] > 15

    These variables are combined with many others into conditions for trade entries.

    #136268 quote
    robertogozzi
    Moderator
    Master

    Try using an integer numeber of periods for the short ADX.

    #136276 quote
    Nicolas
    Keymaster
    Master

    Check all divisions in your code, are they made with a variable not initialized (with no value)?

    #136299 quote
    teapot2002
    Participant
    Average

    robertogozzi – that fixed it. Thank you.

    #136569 quote
    teapot2002
    Participant
    Average

    For anyone who does what I did….I came up with these ADX values through optimisation. Although I wasn’t familiar with ADX, I now realise that these are strange values. With ADX[1.4], the code running on the 5m minute chart was stopped every 5 minutes. To correct it, I made an integer, but rounded down, so ended up with ADX[1]. This time, the code lasted longer than 5 minutes, but eventually was stopped. When I changed it to ADX[2], it ran consistently without failing.

    GraHal thanked this post
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

ADX causes 'divide by zero' error?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
teapot2002 @teapot2002 Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by teapot2002
5 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/17/2020
Status: Active
Attachments: No files
Logo Logo
Loading...