Division by zero ERROR

Forums ProRealTime English forum ProOrder support Division by zero ERROR

Viewing 5 posts - 16 through 20 (of 20 total)
  • #135531

    Hey guys!

     

    i still get the same error, division by zero…. only difference now is that it takes a few hours before it stops, i inerted the code for the strat and the vwap indicator

    #135551

    Hi, sorry to ask if you’ve already checked, but just in case : if running the strategy on cfd on 24h basis, considering it calls Vwap which requires volume data in denominator, do you have in place somewhere a safeguard in order to avoid the first few bars of the day with no volume where it’s not possible to have a vwap?

    The safeguard   max(1,intradaybarindex)   on line 1 of vwap code protects you from having no bar to make the summation on, ok… But if calculated too early on bars with no volume on a cfd Germany30 instrument before 2.15am when Dax futures market opens, it won’t prevent in line 3   summation[d](volume)   from summing zero’s resulting in a division by 0 for vwap.

    2 users thanked author for this post.
    #135565

    okay, so that means i cant use vwap in the strat? or is there a way to work around that problem?

    #135735

    As far as vwap is concerned there are several easy ways you could improve this vwap code.

    Moderator hat on, considering plenty of beginners recently joined, I would have to suggest most of these ways probably are already in the forum past topics, either in the “similar topics” suggested just after the last messaeg of this page (and just above the reply box), or reachable with the search box on the site frontpage (or in the drop down menu from your avatar top right corner of this page).

    But taking the moderator hat off and putting the “prt user just like anyone else” hat on, I’ll go further and suggest adding an “if” statement to avoid candles when volume=0. It would avoid the inelegant way of selecting time which would make the code not compatible with other instruments for which volume does not start at the same time. Something like:

    Of course you would have to check vwap=0 doesn’t introduce problems in the main code calling the vwap code (like not dividing by vwap…)

    However, maybe it won’t solve it all in case you might be in a multiple bugs hunt here, but at least it opens you the door to finding your next bug. Because I see 2 things on page 1 :

    1) it doesn’t seem to be the same vwap code you were calling, so the unseen full vwap initial code might need more cleaning up.

    2) you mentionned having the problem early on in the strategy before, assuming that’s in the same day as launching the strategy, that couldn’t be because of vwap at night, it is likely there remains something else to solve…

    Anyway, I hope it helped at least a little bit, good luck.

     

    #135748

    Above code added as Log 222 to here …

    Snippet Link Library

Viewing 5 posts - 16 through 20 (of 20 total)

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