Does the TIMEFRAME keyword accept numeric constants only?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #201701 quote
    geier777
    Participant
    New

    How can I store a timeframe value in a variable?

    I have tried the following code, but it is not accepted:

    tf1 = 5 minutes
    tf2 = 15 minutes
    
    //timeframe tf1
    timeframe (tf1)
    tf1myMACD=exponentialaverage[12]-exponentialaverage[26]
    
    //timeframe tf2
    timeframe (tf2)
    tf2myMACD=exponentialaverage[12]-exponentialaverage[26]
    
    timeframe (default)
    return tf1myMACD, tf2myMACD
    

    Thanks for your support.
    Walter

    #201702 quote
    Philstrading
    Participant
    Senior

    You should create a new topic for that really

    However I dont think you can.

    You can create a variable within a timeframe and use that, but timeframe code itself can’t be stored differently as far as I’m aware.

    Best thread is https://www.prorealcode.com/blog/learning/approach-multi-timeframe-trading-prorealtime/

     

    Generally you have to create your variables within the specified timeframes you want them in, but timeframes themselves are unable to be stored as variables… The logic of coding is to select the timeframe you want to get data from and use the variables within your code. The above thread will help to see how that can be used within the default timeframe being used.

    #206113 quote
    LivJoJade
    Participant
    New

    Somehow I don’t think this is possible. I have written a probacktest and indicator (see attached) using 2hr, 1hr,30 minute and 15 minute timeframes. Each time I’m told to use a 5 minute timeframe because all timeframes are divisable by 5 minutes. I’ve also tried using the TIMEFRAME (default) command but alas, no joy.

    Is it possible guys?

    Many thanks in anticipation.

    #206134 quote
    robertogozzi
    Moderator
    Master

    @geier777

    I created a new topic. Do not append different questions to existing topics, as suggested by Philstrading, as this would make it difficult to search the correct infos, when needed. Thanks 🙂

    As stated in the prior post, it’s not possible to use variables with the TIMEFRAME keyword.

    #206146 quote
    LivJoJade
    Participant
    New

    My apologies Robert.

    While off sick today I’ve played with the probacktest and am getting entries on the 15 minute chart, however the issue I’m now having is exit of positions, for some reason the backtest is not recognising the exit conditions.

    Many thanks in anticipation.

    #206149 quote
    JS
    Participant
    Senior

    Hi

    When I backtest your system “Bolly” on a time frame of 5 minutes then there are no problems…

    Both long and short trades…

    #206154 quote
    LivJoJade
    Participant
    New
    good afternoon 1st of all many thanks for your reply. The code doesn’t seem to have an issue entering trades, it is the exit criteria. trades should be exited when the hourly close hits 50 RSI?
    #206156 quote
    robertogozzi
    Moderator
    Master
    It’s because of the missing UPDATEONCLOSE keyword (hence the DEFAULT keyword is assumed), as your chart will display a wrong RSI at closing time, while when the 1-hour bar is forming it happened to be in the correct range.
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

Does the TIMEFRAME keyword accept numeric constants only?


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
geier777 @geier777 Participant
Summary

This topic contains 7 replies,
has 3 voices, and was last updated by robertogozzi
3 years, 1 month ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 09/30/2022
Status: Active
Attachments: 4 files
Logo Logo
Loading...