Division by Zero Error: Trading system was stopped
Forums › ProRealTime English forum › ProOrder support › Division by Zero Error: Trading system was stopped
- This topic has 50 replies, 4 voices, and was last updated 4 years ago by GraHal.
-
-
06/17/2020 at 3:51 PM #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.
- / (open-close) line 133, 479
- / (close-open) line 223, 311, 873, 903, 995
- / 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
06/18/2020 at 7:44 AM #136338For 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.
06/18/2020 at 11:41 AM #136398Hi 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/TradeRiskI 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.
06/18/2020 at 11:45 AM #13640006/18/2020 at 11:51 AM #136403Here is a link to the file on Google Drive.
https://drive.google.com/file/d/1Oc0u7z2N1kJremBpP0lG3cSYUG8a4KOv/view?usp=sharing
06/19/2020 at 4:28 PM #13657906/19/2020 at 5:30 PM #136589I 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.
06/19/2020 at 6:04 PM #13659006/19/2020 at 6:05 PM #13659206/19/2020 at 7:10 PM #136593You 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?
06/19/2020 at 7:16 PM #136594In 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.
06/19/2020 at 8:02 PM #136595During 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).
06/19/2020 at 8:23 PM #136596Some 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 accountWhen you say some systems and 21 systems … are these 21 systems all variations on the .itf you posted above?
06/19/2020 at 8:24 PM #136597all trades show up normally.
So over 100000 bars on eurusd on 10 min TF how many trades do you get?
06/19/2020 at 8:46 PM #136598It 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).
-
AuthorPosts
Find exclusive trading pro-tools on