ProOrder Exception Line Number
Forums › ProRealTime English forum › ProOrder support › ProOrder Exception Line Number
- This topic has 7 replies, 4 voices, and was last updated 4 years ago by Ξ3.
-
-
07/27/2020 at 4:30 PM #140221
Hi All,
I have a fairly complex piece of automated code running on IG ProRealTime 10.3 that on the odd occasion comes up with a divide by zero error when using multi-timeframe… I suspect it might be due to a “phantom” bar but have gone through my code in detail yet I am unable to identify where the problem is sneaking in.
Is there any way to get a rough idea of which line in the code causes this exception (or at least somehow narrow it down a bit)? I can’t seem to find any indication on any error message? Of course it works perfectly during back-testing 😉
Any help or ideas would be greatly appreciated.
07/27/2020 at 4:47 PM #14022507/27/2020 at 6:08 PM #140228Good advice Nicholas but I have gone through my code and put IF statements around all divisors to protect against zero (or at least that’s what I thought). I guess the answer is that there is no place find the actual offending code or line number in any error message? 🙁
07/28/2020 at 7:01 AM #140251I do not know any other “exception” way to debug this issue. PRT is more like a simple scripting language thus it doesn’t offer many features from the common programming language (e.g. exception, function block, etc…) although it keeps improving.
From my experience on one occurrence for division zero issue (which for some reasons back test doesn’t catch it), you can pay attention to the timing when the zero division error message happened (PRT should send you a notification when it happen) and from there, you can observe from chart what information has gone wrong.
Like below, I have to add condition “IF bolltrendUP = bolltrendDOWN THEN”, otherwise, they can end up with same value and when going to (bolltrendUP – bolltrendDOWN), it is zero. I only find it by focusing on the timing when the error happens and I put up the indicator and see for myself.
It happened on MTF as well for me, the bolltrendperiod and strend were rather small thus resulted such issue occasionally.
12345678910bolltrendMA = average[bolltrendperiod, 1](close)//50,1STDDEVtrend = STD[bolltrendperiod]bollstrend = strend * STDDEVtrendbolltrendUP = bolltrendMA + bollstrendbolltrendDOWN = bolltrendMA - bollstrendIF bolltrendUP = bolltrendDOWN THENbolltrendPercent = 50ELSEbolltrendPercent = 100 * (close - bolltrendDOWN) / (bolltrendUP - bolltrendDOWN)ENDIF07/28/2020 at 7:18 AM #140253Out of curiosity, I tested with this simple code, the back test doesn’t give me any error. When 4 / 0 happens, C2 just equal to 0 and test continue to next trade.
So back test cannot catch division zero…maybe can be an improvement to send to PRT
1234567891011121314151617181920212223// Conditions to enter long positionsMA20 = ExponentialAverage[20](close)IF barindex > 0 AND barindex mod 2 = 0 THENa = 2ELSEa = 0ENDIFC1 = close > MA20C2 = 4 / a = 2IF NOT LongOnMarket AND C1 AND C2 THENBUY 1 CONTRACTS AT MARKETENDIF// Conditions to exit long positionsIf LongOnMarket AND barindex - tradeindex = 70 THENSELL AT MARKETSET STOP %LOSS 5ENDIFGRAPH aGRAPH C1GRAPH C21 user thanked author for this post.
07/28/2020 at 7:33 AM #14025607/28/2020 at 12:29 PM #140295Have also had my fair share of this problem. Something I have picked up is that if division happens with a variable that is perhaps undefined at any particular stage you will also get that error.
Can be mitigated by using prober initiation parameters i.e. once
07/28/2020 at 12:34 PM #140296 -
AuthorPosts
Find exclusive trading pro-tools on