Division by Zero Error: Trading system was stopped

Forums ProRealTime English forum ProOrder support Division by Zero Error: Trading system was stopped

Viewing 15 posts - 1 through 15 (of 51 total)
  • #136272

    Hello,

    My trading system was stopped because of a “division by zero error”. However I can’t find the reason. I’ve read all Forum threads on this topic to make sure I use what others have shared before.

    In backtesting mode everything goes well without errors. But when I started running it on the demo account, the error started to come up.

    The system or systems is pretty long (over 2300 lines). For “Long” it has 8 setups with each 10-15 entry conditions. But the major part are the no-entry conditions. There are a total of 187 no-entry conditions over 3 time frames (66 on 10m, 92 on 1hr, 29 on 4hr). For “Short” it should be roughly the same.

    The reason for all those no-entry conditions is all the various candlestick combinations that I observed that caused trades to fail.

     

    I used the code for 7 different FX pairs on 3 times frames (10m, 15m and 1hr charts) and with some I have either winning trades, losing trades or no trades and the system has not been stopped yet.

    But with others after some time, the system is stopped.

    I went through the “Long” side of the code to identify all the moments there is a division and there are basically 3 possible scenarios from my perspective.

    1.  / (open-close) line 133, 479
    2.  / (close-open) line 223, 311, 873, 903, 995
    3.  / Traderisk line 646

    But somehow is seems unlikely that, for example, open and close are the same so often. When I checked the charts after the system was stopped I never could identify this. That’s why I am confused.

     

    I would appreciate any help on this issue.

    I’ve spent already 400 hours of coding during the last 4 months for this system / systems and it would be nice to get some reward at some point.

     

    Thanks.

    Sascha

    #136338

    For points 1 and 2: Add a preloadbars = 10000 at the top of the code. At launch of the system if the candlestick OHLC is not present for a reason, that will be lead to a division by zero error.

    3/ are you sure the traderisk variable is correctly calculated and never reset to 0? The code is read from top to bottom, make sure this variable is calculated before it is used as a divisor.

    #136398

    Hi Nicolas,

    The preloadbars is already set to 10000, so the problem shouldn’t come from there.

    The TradeRisk in line 646 and 1991 is only calculated two lines before like shown below. So I don’t see how this could be a value of zero.

    ISL = 10000*(2*ATR) //((close+2*ATR)-close)
    TradeRisk = pipvalue*ISL
    ContractSize = 100/TradeRisk

    I also tested a version where I deleted the above three lines of code and simply gave a fixed number of contracts to buy or sell and the system was also stopped due to Division by Zero.

    I’ve attached the code as ITF-file.

    Any further help would he highly appreciated.

    Thank you.

    #136400

    I can’t seem to upload a file. I tried to upload a Word and ITF-file and it doesn’t show up.

    #136403
    #136579

    Hi,

    Any thoughts from anyone in the forum who has solved this issue in the past?

    Help highly appreciated.

    #136589

    I tried to upload a Word and ITF-file and it doesn’t show up.

    Try again to attach just the .itf file.  We all do it all the time so it should work no trouble.

    Tried to access your google drive and need access etc.

    #136590

    @GraHal:  I’m sorry that it doesn’t work. I select the file and submit and did it five times in the last 2 minutes and nothing happens. Not sure what the issue is.

    #136592

    Well, now it worked.

    #136593

    You reference so many bars and it likely would only need one of those bars to not exist to give the divide by zero error?

    When does the divide by zero error occur … when you try and start the  Algo in ProOrder or when the Algo tries to execute a trade or random occurence?

    #136594

    In backtest … does your Algo take any trades?

    If Yes … on what Instrument and Timeframe?

    If No … my thinking is that if the backtest takes no trades then that may be an indication that one or more of the many bars you reference is missing??

    I doubt there would be a 10 min bar missing, so just thinking aloud really.

    I can’t get any trades on backtest on EURUSD, DAX or DJI.

    #136595

    During back testing everything works fine. No error messages and all trades show up normally.

    When I let it run in my IG Markets Demo account that’s when the system was stopped with this error message. It seemed random because I also had many trades that were executed normally.

    Some systems were stopped after a few minutes or a few hours and some not at all so far.

    I  set up 21 Algos in my demo account using 7 FX pairs (EURUSD, GBPUSD, AUDUSD, NZDUSD, USDCHF, USDCAD, EURGBP) and 3 timeframes (10m, 15m 30m). So it’s 21 times the same system.

    The systems are made for Forex (non JPY pairs). You wouldn’t be able to get any trades on DAX or DJI).

    #136596

    Some systems were stopped after a few minutes or a few hours and some not at all so far.
    I  set up 21 Algos in my demo account

    When you say some systems and 21 systems … are these 21 systems all variations on the .itf you posted above?

     

    #136597

    all trades show up normally.

    So over 100000 bars on eurusd on 10 min TF how many trades do you get?

    #136598

    It is 21 times the same system, which is the ITF file I’ve uploaded.

    There are trades everyday but not on every FX pair. Maybe 4-6 trades everyday on those 7 pairs on the 10min time frame,  4-6 trades on the 15m and  1-3 trades on the 30m.

    Not sure why you mentioned 100000 bars. In my back testing I use 1000 bars on the 10min.

    On the AUDUSD  10m today there were 3 trades (see picture attached).

Viewing 15 posts - 1 through 15 (of 51 total)

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