Division By Zero Error

Forums ProRealTime English forum ProOrder support Division By Zero Error

Viewing 2 posts - 1 through 2 (of 2 total)
  • #237070

    Good Day Everyone,

    this is about another division by zero issue. It does happen to me with various instruments (NDX, DAX etc.) only within the 1M time frame.
    I checked other forum posts and tried a few things: -volume is > 0, -only execute in a selected time frame, -tried the min and max function

    Here is part of the code (I think it happens with “mySTOLong = STOCHASTIc…”, if I set it the mySTOLong value to 0 it does work).
    And of course every time it stops i see that close = open and open = high and high = low….

    Any idea or comment is highly appreciated!

    Thx Oliver

     

    #237071

    Hi,

    it might be because with mySTOnLong=1, this means the stochastic calculation is made with a division of high-low, and that would indeed be worth zero when high=low.

    Maybe an if statement checking high vs low for mySTOnLong=1, or >1 on its own (although it might happen again with mySTOnLong=2 if 2 consecutive candles with twice same high=low, but not as frequently, a more general condition could be written if that’s the case):

    if (mySTOnLong=1 and high<>low) or  mySTOnLong>1 then

    mySTOLong = STOCHASTIc[mySTOnLong,mySTOkLong](close)

    else

    mySTOLong = // choose what default value to give when high=low and stochastic cannot be calculated over a span of mySTOnLong=1

    endif

    1 user thanked author for this post.
Viewing 2 posts - 1 through 2 (of 2 total)

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