Using multiple timeframes in code

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #171902 quote
    JaldideeJaldidee
    Participant
    Average

    Hello Everybody,

     

    Hope someone can help me. For a while i was having no trouble with a tradingsystem that run on multiple timeframes. On the four hour chart it watsches the historic volatility and on the 5 minutes charts i watch the trend . The system has worked perfectly, but suddenly i got the error that there was a division by zero.

    I checked everything and pinpointed it to the coding i use to first check the 4 hour chart and use this as a condition in my 5 minute chart.

    The coding without multiple timeframes was:

    DEFPARAM CumulateOrders = False
    
    DEFPARAM FLATBEFORE = 080000
    
    DEFPARAM FLATAFTER = 220000
    
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    ONCE Nbbarlimit = L
    
    var1 = ExponentialAverage[20](close)>= ExponentialAverage[100](close)
    var2 = High[0] < High[1]
    var3 = Low[0] > Low[1]
    var4 = ExponentialAverage[20](close)<= ExponentialAverage[100](close)
    var5 = myhv >= B
    
    indicator1 = CALL "Moving Average"[20, 1](close)
    
    
    c1 = (indicator1 >= 8)
    C2 = (indicator1 <= -8)
    
    IF not onmarket and var1 AND var2 AND var3 and C1 then
    

    When i add the coding for the multple timerframes it now gives the error “divison by 0”. Does anybody know what i am doing wrong?

    DEFPARAM CumulateOrders = False
    
    DEFPARAM FLATBEFORE = 080000
    
    DEFPARAM FLATAFTER = 220000
    
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    timeframe(4hour)
    myhv = HistoricVolatility[20](close)
    
    timeframe(5minute)
    ONCE Nbbarlimit = L
    
    var1 = ExponentialAverage[20](close)>= ExponentialAverage[100](close)
    var2 = High[0] < High[1]
    var3 = Low[0] > Low[1]
    var4 = ExponentialAverage[20](close)<= ExponentialAverage[100](close)
    var5 = myhv >= 0.12
    
    indicator1 = CALL "Moving Average"[20, 1](close)
    
    
    c1 = (indicator1 >= 8)
    C2 = (indicator1 <= -8)
    
    IF not onmarket and var1 AND var2 AND var3 and C1 then
    

    kind regards,

    Jaldidee

    #171903 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    A “division by zero”error is expected to be reported by a division,

    I can’t spot any division in your code, so it’s impossible to know the source.

    Maybe there’s a division in the indicator or in the missing code.

    #171912 quote
    NicolasNicolas
    Keymaster
    Legend

    Check your “Moving Average” indicator’s code for any division.

Viewing 3 posts - 1 through 3 (of 3 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

Using multiple timeframes in code


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Jaldidee @jaldidee Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/16/2021
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...