Division by zero Stopping Trading System

Forums ProRealTime English forum ProOrder support Division by zero Stopping Trading System

Viewing 10 posts - 1 through 10 (of 10 total)
  • #139550

    Hi, this system code below is causing a “Division by Zero” system stop out issue twice since being launched last week.

    Is anyone able to find the line of code that is causing the problem? It tested fine and well on back test (Wall Street DFB).

    Cheers, much appreciated for any help.

     

    #139552

    What TF are you running?

    The error messages (divide by zero etc) may not always be accurate.

    If you are running on 1 sec TF then maybe the code above occasionally does not fully execute in 1 second and so the divide by zero error code is thrown up?

    Unless I can quickly spot the cause (for divide by zero etc) I generally start the System back up again and think … “life is too short … I’m not going to get frustrated looking for a problem that may not even exist in the code !!??” 🙂

    PS

    Good to see you back … I thought you may have moved on to pastures new! 🙂

    #139560

    Hey GraHal, cheers, likewise and thanks for the help, right, it’s a daily TF and it was stopped out within 24 hours of putting it back up after the first stopped out the day before.

    You know when Juanj said (regarding his ML post topic), words to the effect that this was just “the tip of the iceberg,” well, because I had to take time off from sitting at the desk and 50″ trading screen because of an old back injury flare up (compressed nerve), I went and listened to a lot of Kraftwerk, Stranglers and The Undertones and read everything I could on ML. Please read this phd thesis paper, it will blow your mind:

    https://www.researchgate.net/publication/328838338_Automated_Stock_Market_Trading_Using_Machine_Learning

    The pdf download link is in blue, top right.

    I’m learning to use RapidMiner presently but Gabri (Gabriele) is saying that Python is pretty good too. The hardest and critical part of ML is data preparation. I’m using Excel, and have already programmed all the indicators used in the research paper but would like to add more complex indicators like ones by John Ehlers, so I posted an “Excel collaboration” idea in the forums: https://www.prorealcode.com/topic/collaboration-to-code-indicators-into-excel-file/

    I’m also thinking of maybe getting either a Trading View subscription or Interactive Brokers account because they both let you download O/H/L/C/V and indicator values to Excel which you’ll need. The idea is that the you’ll need to de-trend the noise out of the time series and use volatility data too. Luke Rose’s research paper only used generic indicators though but got incredible 30 and 200 day trend prediction results using Random Forests. Then again he was using the Nasdaq stocks which go up generally, I want to see how accurate it is for mean reverting currencies.

    Let me know what you think?

    #140232

    Anyone?

    Tried using if positionperf (i)<>0 for lines 124, 226 and 331 but it still got stopped out.

    #140237

    Try GRAPHing

    • optimise
    • optimise2
    • optimise3
    • heuristicscycle

    I didn’t, but at first glance it looks like some of them could be the problem.

     

    1 user thanked author for this post.
    #140254

    I made a simple test that shows back test cannot alert your strategy has division zero issue, you can refer to here, https://www.prorealcode.com/topic/proorder-exception-line-number/#post-140253

    On the same post, I also shared my experience to pay attention to the timing when PRT notify you the division zero error, i.e. the date and time, and use it as your input for debugging. In your case, maybe you can graph all the division and pay attention which variable give you zero on the particular timing or nearby timing in case some delay in sending the notification, but at least it narrow down your debugging range.

    1 user thanked author for this post.
    #140281

    Hi I’m not exactly a pro coder and it may be something to do with the insert PRT code but every time you use “increment” or “maxincrement” it sees the “rem” and turns it into a remark.

    The earliest lines of this is lines 33 and 35.

    I’ve not used anything like that in my codes so not sure if that’s what happens in the real PRT.

    1 user thanked author for this post.
    #140521

    Cheers @robertogozzi !
    I’ll take a look this weekend.

    #140529

    Thanks @DowJones for taking the time to help identify this division by zero issue and for the link. I’ll be paying more attention to the time when PRT send the system stopped email.

    #199087

    The division by zero may occur on lines 412 or 415

    Passing the both lines as remarks as below, you will avoid the division by zero. But the results will be slightly different as you will be in position for longer periods.

    412 //renkomaxl <span class=”crayon-o”>=</span> <span class=”crayon-st”>round</span>(<span class=”crayon-st”>close</span> <span class=”crayon-o”>/</span> boxsizel) <span class=”crayon-o”>*</span> boxsizel

    415 //renkomaxs <span class=”crayon-o”>=</span> <span class=”crayon-st”>round</span>(<span class=”crayon-st”>close</span> <span class=”crayon-o”>/</span> boxsizes) <span class=”crayon-o”>*</span> boxsizes

Viewing 10 posts - 1 through 10 (of 10 total)

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