Timeframe 28s and error division by 0
Forums › ProRealTime English forum › ProOrder support › Timeframe 28s and error division by 0
- This topic has 3 replies, 3 voices, and was last updated 3 years ago by danistuta.
-
-
05/25/2020 at 11:24 AM #133161
I’m testing this code, taken from this forum. However running on IG demo sometimes it stop with an error regarding bar closing and division by “0”. Could you help me to solve it? Thank you very much.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192//-------------------------------------------------------------------------// Codice principale : Boll/WR 28 sec EUR/USD//-------------------------------------------------------------------------DEFPARAM CumulateOrders = False // Cumulating positions deactivated//DEFPARAM FlatAfter = 225500perdita=21guadagno=8//k=27ctime =(time>=010000 and time<=080000) or (time>=100000 and time<=110000) or (time>=130000 and time<=140000) or (time>=180000 and time<=190000) or (time>=210000 and time<=220000)timeframe (560 seconds, updateonclose)//ST=Supertrend[3,10]m1=ADX[14]>27timeframe (default)// Conditions to enter long positionsindicator1 = BollingerDown[7](close)c1 = (close <= indicator1)indicator2 = ADX[14]c2 = (indicator2 >= 42)indicator3 = Williams[56](close)c3 = (indicator3 <= -96)// Conditions to enter long positionsindicator5 = BollingerDown[7](close)c6 = (close <= indicator5)indicator6 = ADX[14]c7 = (indicator6 >= 44)indicator7 = Williams[1](close)c8 = (indicator7 <= -75)// and close> ST and m1IF (c6 AND c7 AND c8) or (c1 AND c2 AND c3) and ctime and m1 THENBUY 1 CONTRACT AT MARKETENDIF// Conditions to exit long positionsindicator4 = Average[58](close)c4 = (close CROSSES OVER indicator4)c5 = (close CROSSES UNDER close[1])indicator8 = Average[6](close)c9 = (close CROSSES OVER indicator8)c10 = (close CROSSES UNDER close[1])IF (c4 AND c5) or (c9 and c10) THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator9 = BollingerUp[25](close)c11 = (close CROSSES OVER indicator9)indicator10 = ADX[5]c12 = (indicator10 <= 23)indicator12 = BollingerUp[24](close)c15 = (close CROSSES OVER indicator12)indicator13 = ADX[12]c16 = (indicator13 <= 16)// and close<ST and m1IF (c11 AND c12) or (c15 and c16)and ctime and m1 THENSELLSHORT 1 CONTRACT AT MARKETENDIF// Conditions to exit short positionsindicator11 = Average[23](close)c13 = (close CROSSES UNDER indicator11)c14 = (close CROSSES OVER close[1])indicator14 = Average[20](close)c17 = (close CROSSES UNDER indicator14)c18 = (close CROSSES OVER close[1])IF (c13 AND c14) or (c17 and c18) THENEXITSHORT AT MARKETENDIFIF time=225500 THENEXITSHORT AT MARKETSELL AT MARKETENDIF// Stops and targetsSET STOP pLOSS perditaSET TARGET pPROFIT guadagno05/25/2020 at 11:45 AM #133165Unless it’s the number [1] with WILLIAMS, I don’t really know what to tell you, I don’t think there are any calculations that can return 0 in an expression.
Try using [2].
05/25/2020 at 11:45 AM #133166It may be due to no data for one or more bars under test?
Anyway, I was involved in this strategy (I think or another 28 sec TF one) and 28 sec is not a good TF. 30 sec is much better!
If you work it out … 28 sec, 56 sec, 84 sec etc on which you may have backtested and then you start a Forward Test on 11: 41 (for example because that is the time now! 🙂 then 28 sec later will be … oh you do the maths! But backtest likely is not at the same points of for example a 1 minute bar as for example 30 seconds is … 2 x 30 sec bars per minute.
Best thing is you find the Topic where we had loads of discussion on 28 sec TF before maybe you spend a chunk of your life on it?? 😉
1 user thanked author for this post.
05/25/2020 at 1:00 PM #133176 -
AuthorPosts
Find exclusive trading pro-tools on