Division zero error
Forums › ProRealTime English forum › ProOrder support › Division zero error
- This topic has 34 replies, 4 voices, and was last updated 1 year ago by GraHal.
-
-
03/28/2023 at 2:22 PM #212306
Hi,
My systems stops with this error “The trading system was stopped due to a division by zero in one of its sub-functions during the evaluation of the last candlestick. You can add protections to your code to prevent divisions by 0 then backtest the system to check the correction.”
Backtest also looks fine.
Nothing is divided by zero. Can it be something else?
03/28/2023 at 2:35 PM #21230703/28/2023 at 4:16 PM #212315I have checked all values in each division noone is 0. I call for all the indicators.
I run the algo wihtout calling the indicators and that works fine. But the other version when i Call each indicator with exact same numbers I get the error. Even though backtests are exact same.
There is one tiny different, which I dont think matters? The one wihtout calling has DEFPARAM preloadbars = 5000 and the calling one has DEFPARAM preloadbars = 10000
03/29/2023 at 9:53 AM #21239403/29/2023 at 12:37 PM #21242103/29/2023 at 12:41 PM #21242203/30/2023 at 4:44 AM #212473As I mentioned none of the divisions are 0.
Franro, You won’t know that because internally all sorts of other commands are executed (think like 10 commands get in place of one command you wrote). So it requires imagination of what is implied.
I would say that a sub function is something you would explicitly Call. But you are correct in thinking that it could be anything. PRT development likes to give their own “names” to existing phenomena. But also think of the translation to English. In French it could have been “Sub Routines”. That is a normally existing phenomenon and now it will be about some routine you call indeed. Can be an indicator – can be any code you have written/gotten in .itf form – and call.
If you are not going to show the code and also the code(s) of what is called, then here it stops. Even with code these things are some times tough to solve or work around.
It is not a bad idea to think that this could be a PRT bug. But in any event, take care that you have sufficient DefParam PreLoadBars pre-loaded. For this, observe all your functions like Average and all, and envision how many bars they would require to do their work in full.
1 user thanked author for this post.
03/30/2023 at 8:51 AM #21250503/30/2023 at 9:03 AM #212507Alright thanks guys. One more question, if I have the EXACT same algo running wihtout call functions and one with call function. Can the call function strategy get repeatidly errors and the other one dont, even though all indicator is the same? Both show same backtest. And both ran on demo accounts on different accounts.
03/30/2023 at 10:36 AM #212522A track with the CALL is to use fixed rather than variable parameters in your call, i.e. the indicator must not have external parameters, if it is possible to do so opposite your strategy, I suggest you give it a try. If you don't want to share the code on the forum, it is possible to create a support ticket that could go deeper and find a solution to your problem.
1 user thanked author for this post.
04/03/2023 at 1:23 PM #21272404/03/2023 at 1:34 PM #21272504/03/2023 at 1:41 PM #212726Im not sure but maybe below occur division 0? But how can I try this and be sure?
maybe this?1234567891011lengthRSI = 3lengthStoch = 3smoothK = 5smoothD = 2myRSI = RSI[lengthRSI](close)MinRSI = lowest[lengthStoch](myrsi)MaxRSI = highest[lengthStoch](myrsi)StochRSI = (myRSI-MinRSI) / (MaxRSI-MinRSI)K = average[smoothK](stochrsi)*100D = average[smoothD](K)cl = K>D04/03/2023 at 3:23 PM #21273404/03/2023 at 4:20 PM #212735 -
AuthorPosts
Find exclusive trading pro-tools on