Division By Zero Error: Solved

Forums ProRealTime English forum ProOrder support Division By Zero Error: Solved

Viewing 13 posts - 1 through 13 (of 13 total)
  • #45869

    Good Day Everyone

    For those of you who have had issues with strategies stopping due to the division by zero issue, despite making provision to contain it I have found another cause and possible solution.

    Other than the obvious reasons such as actual division by zero or division by undefined/null variables here is another cause I identified:

    During weekends or outside market hours there are obviously no prices/quotes available and hence any calculation that requires such information will not be able to be calculated i.e. range

    Thus containing your whole code (the parts that make sense obviously) inside an If statement that only executes/evaluates during market hours/weekdays you can effectively eliminate the division by zero error caused due to this particular reason.

    Hope some of you might find this useful.

    Regards

     

    9 users thanked author for this post.
    #127267

    @juanj you make a good point about out of hours and no data which could cause this error but the systems should be paused by IG during “market closed” times and we should not get this error due to a market being closed. I’ve had a few instances when a systems still tries to calculate even though the market is closed.

    I’m having this error: Division By Zero Error

    The strange thing is that it’s somewhat inconsistent. I have one instance of a system on Demo that is running without the error on h1 but on m1 I get the error.  In a live account on h1 I had this error occur and the system closed. It still might be due to an error in my code which I’m trying to find (and probably is the cause) but the inconsistency of running without error on h1 and error on m1 is what has me puzzled.

    #127271

    but the inconsistency of running without error on h1 and error on m1 is what has me puzzled.

    It probably will be as Juanj says … on 1 min TF there will be a bar missing / no data.

    But on 1 hour TF there will be a bar for 1 hour (doubtful no bar for 1 whole hour? ).

     

    #127275

    @GraHal there’s data on the m1 (okay let’s assume there’s not) but how about: In a live account on h1 I had this error occur and the system closed?

    #127278

    In a live account on h1 I had this error occur and the system closed?

    But you said …

    but the inconsistency of running without error on h1 and error on m1 is what has me puzzled.

    Anyway have you clicked the setting / box on both Demo and Real Live to say Close trades if System stops?

    Also when I said no data on M1 … I only meant like for 1 minute / bar there might be no data?

    #127280

    @Grahal why should it matter if I “clicked the setting / box on both Demo and Real Live to say Close trades if System stops.”  the system stops (I see I wrote “closed” but I meant “stops”) because of the supposed “division error”.

    The issue is the supposed error and not if the orders are closed or remain open or am I misunderstanding something?

    #127283

    am I misunderstanding something?

    No … it’s more likely me not spending enough time reading and thinking etc.

    Why don’t you post your code on here? The experts may spot something that is causing the problem?

     

    #127996

    I ran older version of my code on a Demo and it was working for a few days then I got this error.

    One of the orders of this trading system was rejected. Due to the type of rejection, the trading system had to be stopped…

    The Rejected error information is:

    You have requested a closing transaction but either you have no open position in that market, or the size is greater than your existing position. 

    The code has 2 types of close orders:

    When the system stopped because of the above error the SELL AT x LIMIT had closed 2 open BUY trades (as you will see in the attacehment) and then at the start of the next bar PRT ran the code and my guess is that for some reason it still thought there might have been an 2 open trades and tried to close them based on the floatingProfitValue but there was no longer any trades open. This is further supported by Order List report (attached). Furthermore, PRT  kept trying to close the orders more than 11 times when it should have stopped them system unless something has changed with that 11 attempts/failure rule that I’m not up to date with?

    Another interesting point is that at first “Pos. Chg” was

    2 => 1
    2 => 1
    … for 12 times and then it went
    1 => 0
    then back to
    2=> 1

    The error:

    You have requested a closing transaction but either you have no open position in that market, or the size is greater than your existing position. 

    The thing is this system had completed many trades with the same conditions and no errors had occur but then randomly this time it had this issue.

    I know this is different to the previous division By Zero Error but I think it might be related or the same but I just got a different error because on this occasion there were no open orders while with the “Division By Zero” I still had open orders.

    I will send a report to PRT to see if they can identify if there’s an issue with the engine because that’s what I think is happening.

    #184222

    Hello folks!

    Sharing my experience: : I keep experiencing the same problem again and again on NQ 1min TF and tried to check on the graph the candles where the system stops. The problem typically happens outside of normal trading hours. The problem in my case isn’t a division per zero as the PRT message says, it’s rather the size of the body of the current candle and/or the difference between the prices of the current candle and the previous candle. Very small difference (<0.5pts) body of the candle and/or current vs previous generates errors when (1) you have conditions including size of the candle and/or comparison with the previous candle and/or (2) minimum distance of SL required by the broker. This problem happens to me independently whether the Algo is in position or waiting for a signal.

    Happy New year to all!

    #184224

    Use this  code to never drop below 1:

     

    2 users thanked author for this post.
    #184570

    @robertogozzi, I applied the max(1,range) and the error appeared again. I was in front the system, so there was a gap at the open midnight 5 Jan. Any clue how to solve this, because the Algo seems to calculate anyway. Thanks

    1 user thanked author for this post.
    #184575

    The only place where I have the sign “/” in my code is the ALMA

    “/(2*sSlow*sSlow))” this cannot be the problem, since “sSlow = WindowSlow/SigmaSlow”, 8/6 = 1,33

    The other division is “ALAverageSlow = WtdSumSlow / CumWtSlow”, so I added the following and will see for the next few days

     

    #185144

    For what’s worth… For those with IG, who does some maintenance between 23:45 and 00:00 (French time), and who experience problems with their Algos shutting doan (divison by zeron not enough historical data, etc), problem number one identified above is the absence of quotation or gaps, and problem number two is the close=high=low=open.

    See suggestion from Roberto to avoid the problem#184224.

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

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