How to Use a Custom Variable for TIMEFRAME in ProRealTime?

Forums ProRealTime English forum ProBuilder support How to Use a Custom Variable for TIMEFRAME in ProRealTime?

Viewing 2 posts - 1 through 2 (of 2 total)
  • #244935

    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

    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.

     

     

    2 users thanked author for this post.
Viewing 2 posts - 1 through 2 (of 2 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login