TIMEFRAME function

Author: Optuma Team Last updated: Mar 15, 2022 13:33


Available from Optuma 2.0 and onward, the TIMEFRAME() script function allows you to check the source of the dataset being used. This can be useful if wanting to setup scripts that have two different outputs, which you want to control based on the time frame they are applied to.


V1 = MA(BARS=10) ;
V2 = MA(BARS=150, STYLE=Exponential, CALC=Close) ;
V3 = TIMEFRAME() == Day;
IF(V3 == 1,V2,V1)
In the above example the script would display a 150EMA if the charts time frame was set to Daily, and a 10SMA if the charts time frame was set to anything else (weekly, monthly, etc).

Show Plot using the same script applied to a Daily (left) and Weekly (right) chart. The left plot displays a 150EMA, the right a 10SMA.

The Timeframe function also supports a numerical key system as per the following:

  • Minute Timeframe = 1
  • Daily Timeframe = 2
  • Weekly Timeframe = 3
  • Monthly Timeframe = 4
  • Yearly Timeframe = 5