How to Use a Custom Variable for TIMEFRAME in ProRealTime?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #244935 quote
    shiv55shiv55
    Participant
    New

    I’m trying to set a custom tick timeframe dynamically in ProRealTime using the TIMEFRAME() function. However, I found that TIMEFRAME((timeFrame) tick, UPDATEONCLOSE) does not work when timeFrame is a variable.

    I also tried using conditional statements like:

    IF timeFrame = 100 THEN
    TIMEFRAME(100 tick, UPDATEONCLOSE)
    ENDIF
    IF timeFrame = 300 THEN
    TIMEFRAME(300 tick, UPDATEONCLOSE)
    ENDIF

    But that didn’t work either.

    Is there any way to pass a variable to TIMEFRAME() or dynamically change the timeframe without manually editing the script? If not, what’s the best workaround?

    Thanks in advance for any help! 🚀

    #244952 quote
    robertogozzirobertogozzi
    Moderator
    Legend
    The keyword TIMEFRAME does not support variables, such as Timeframe(myTF,UpdateOnClose), only constants. Automated strategies only support time-based timeframes (from Yearly to 1 second), not ticks, range bars, etc… The keyword GetTimeFrame may be used to know which TF is being used, usually to set differents configurations. You can find more at https://www.prorealcode.com/documentation/gettimeframe/, though in the example shown it’s only useful in line 8, as in lines 2 and 5 it already knows which TF is being used, being constants.
    shiv55 and Iván González thanked this post
Viewing 2 posts - 1 through 2 (of 2 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

How to Use a Custom Variable for TIMEFRAME in ProRealTime?


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
shiv55 @shiv55 Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzirobertogozzi
1 year, 6 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/15/2025
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...