Division by zero parameter error on 3 different strategies

Viewing 6 posts - 31 through 36 (of 36 total)
  • Author
    Posts
  • #211699 quote
    robertogozzi
    Moderator
    Legend

    Use

    IF Volume > 0 THEN
     .
     . place any istruction here
     .
    ENDIF
    Johann thanked this post
    #211729 quote
    Johann
    Participant
    Average

    Thanks Roberto will do….

    #211782 quote
    Johann
    Participant
    Average

    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 quote
    Johann
    Participant
    Average

    Roberto,

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

    #211786 quote
    robertogozzi
    Moderator
    Legend

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

    VWSellAvg = NetSell/max(1,NetSellVol)
    Johann thanked this post
    #211794 quote
    Johann
    Participant
    Average

    Thanks Roberto will try that …

Viewing 6 posts - 31 through 36 (of 36 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Division by zero parameter error on 3 different strategies


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Johann @johann Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/03/2023
Status: Active
Attachments: 7 files
Logo Logo
Loading...