Division by zero parameter error on 3 different strategies

Forums ProRealTime English forum ProOrder support Division by zero parameter error on 3 different strategies

Viewing 6 posts - 31 through 36 (of 36 total)
  • #211699

    Use

    1 user thanked author for this post.
    #211729

    Thanks Roberto will do….

    #211782

    Hi Roberto,

    I did add the Volume > 0 to the code but it still seems to stop. I do not know if it could be the VolB = 0 or the VolC = 0? But in the calculation of the indicator I need it to start the count at 0. Any suggestions? See the code below:

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    Timeframe(hourly)
    HTrend = Average[30](close) < Average[80](close)

    Timeframe(default)

    Possize = 1

    // Custom Indicators

    VolB = 0
    Blength = 4
    Slength = 4

    If Volume > 0 Then
    If Close > Open Then
    VolB = VolB + Volume
    if Open = Close and Close – Low => High – Close Then
    VolB = VolB + Volume
    Endif
    Endif
    Endif

    BV = VolB

    TotBuy = Close * BV

    NetBuy = summation[Blength](TotBuy)
    NetBuyVol = summation[Blength](VolB)

    VWBuyAvg = NetBuy/NetBuyVol

    VolS=0

    If Volume > 0 Then
    If Close < Open Then
    VolS = VolS + Volume
    if Open = Close and Close – Low =< High – Close Then
    VolS = VolS + Volume
    Endif
    Endif
    Endif

    SV = VolS
    TotSell = Close * SV

    NetSell = summation[Slength](TotSell)
    NetSellVol = summation[Slength](VolS)

    VWSellAvg = NetSell/NetSellVol

    // Use the cross over signal and RSI value to determine the entry price

    if HTrend and VWBuyAvg[1] > VWSellAvg[1] and VWBuyAvg < VWSellAvg Then
    if rsi[4](close) > 70 Then
    Sellshort Possize contract at market
    Endif
    Endif

    // Stops and targets
    SET STOP pLOSS 230
    SET TARGET pPROFIT 290

     

    #211783

    Roberto,

    I mean VolB and VolS ……… as 0 for the calculation……

    #211786

    Yes, that could be the cause, because if VolS is zero, then VWSellAvg = NetSell/NetSellVol will generate that error.
    Change that line to:

    1 user thanked author for this post.
    #211794

    Thanks Roberto will try that …

Viewing 6 posts - 31 through 36 (of 36 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login