Timeframe 28s and error division by 0

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #133161 quote
    danistuta
    Participant
    Senior

    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.

    //-------------------------------------------------------------------------
    // Codice principale : Boll/WR 28 sec EUR/USD
    //-------------------------------------------------------------------------
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    //DEFPARAM FlatAfter = 225500
    
    perdita=21
    guadagno=8
    //k=27
    
    ctime =(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]>27
    
    timeframe (default)
    
    // Conditions to enter long positions
    indicator1 = BollingerDown[7](close)
    c1 = (close <= indicator1)
    indicator2 = ADX[14]
    c2 = (indicator2 >= 42)
    indicator3 = Williams[56](close)
    c3 = (indicator3 <= -96)
    
    // Conditions to enter long positions
    indicator5 = BollingerDown[7](close)
    c6 = (close <= indicator5)
    indicator6 = ADX[14]
    c7 = (indicator6 >= 44)
    indicator7 = Williams[1](close)
    c8 = (indicator7 <= -75)
    
    //  and close> ST  and m1
    IF (c6 AND c7 AND c8) or (c1 AND c2 AND c3) and ctime and m1 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    
    // Conditions to exit long positions
    indicator4 = 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) THEN
    SELL AT MARKET
    ENDIF
    
    
    // Conditions to enter short positions
    indicator9 = 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 m1
    IF (c11 AND c12) or (c15 and c16)and ctime and m1 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    indicator11 = 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) THEN
    EXITSHORT AT MARKET
    ENDIF
    
    
    IF time=225500 THEN
    EXITSHORT AT MARKET
    SELL AT MARKET
    ENDIF
    
    // Stops and targets
    SET STOP pLOSS perdita
    SET TARGET pPROFIT guadagno
    #133165 quote
    robertogozzi
    Moderator
    Master

    Unless 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].

    #133166 quote
    GraHal
    Participant
    Master

    It 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?? 😉

    robertogozzi thanked this post
    #133176 quote
    danistuta
    Participant
    Senior

    Thank you very much, your updated and last EUR/USD strategy for TF 30s? 🙂

    Thanks.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Timeframe 28s and error division by 0


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
danistuta @danistuta Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by danistuta
5 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/25/2020
Status: Active
Attachments: No files
Logo Logo
Loading...