multiple timeframe – can't read variables of others timeframe

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

    Hi guys

    I’ve reach a problem when I want to do something with 2 timeframe (very simple…).

    I saw in some others strategy that it’s possible to share and use a variable of a specific timeframe in an other one.

    But in my case an error message say that I cannot and that I can read variables of others timeframe.

     

    This is my little example :

    // PING PONG AI - V2 TER
    Defparam cumulateorders = false
    
    ctime = time > 083000 and time < 180000
    
    if not ctime then
    limitH = 0
    //limitB = 0
    endif
    
    timeframe (1hour)
    
    IF Openhour <> openhour[1] THEN
    myLastHigh = myHigh
    myLastLow = myLow
    myHigh = High
    myLow = Low
    ELSE
    myHigh = Max(myHigh, High)
    myLow = Min(myLow, Low)
    ENDIF
    
    if myLastHigh > Myhigh and myLastLow < myLow and ctime  then
    limitH = myHigh
    //limitB = myLow
    endif
    
    timeframe(default)
    
    c1a = close crosses over limitH
    //c1v = close crosses under limitB
    
    if c1a and not onmarket then
    buy 0 contract at market
    set stop ploss 500
    set target pprofit 500
    endif

     

    Do you know the good way to share the parameters with my default timeframe ?

     

    Thanks in advance,

    #136712 quote
    GraHal
    Participant
    Master

    Variables need to have exclusive names for each Timeframe, you can’t share the same name.

    So for example you could name limitB as

    hourLimitH under the 1 hour TF and minLimitH under a 10 minute TF.

    #136713 quote
    robertogozzi
    Moderator
    Master

    You can READ variables from any TF, but they must be created (and their contents changed)  in only one TF!

    You can follow GraHal’s suggestions to keep names quite similar still different.

    GraHal thanked this post
    #136798 quote
    Scooby
    Participant
    Senior

    Nevermind !

    I found why it was not working.

    On line 6 to 8 I reseted the value “LimitH” but not in the good timeframe…

    Sorry for this bad mistake 🙂

     

    Thanks for the support guys 🙂

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

multiple timeframe – can't read variables of others timeframe


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Scooby @scooby Participant
Summary

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

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