Allows to write conditions and/or declare variables in the selected timeframe  (description of the ProBacktest command only on this page).

The syntax of the TIMEFRAME statement is TIMEFRAME (TF, mode) which allows you to put the code in a timeframe different from the main TF, or TIMEFRAME (default) to return to the default TF. “mode” is optional (the default is current bar).

Examples:

  • TIMEFRAME(weekly, UpdateOnClose)
  • TIMEFRAME(30 minutes, default)
  • TIMEFRAME(5 minutes)

List of TimeFrames available: x second (s), x minute (s), x hour (s), hourly, x day (s), daily, x week (s), weekly, x month (s), monthly, yearly

Available modes:

  • UpdateOnClose: only closed bars are used
  • Default: The variables defined in superior timeframes take into account each update of the main timeframe

Using a code on a 1 minute timeframe with:

will return values of the closed bars of the 1-hour timeframe for all codes below this instruction and each 1 minute (code is read at Close), while with:

or

you’ll get the current time values (not closed bars) of the 1-hour timeframe, and each 1 minute (code is read at Close).

 

Example #1:

The strategy is a 1-hour timeframe check for the RSI to cross over the level 50.

Then the order management is made in the 1-minute timeframe:

  • launch an order if the “buycondition” is true (could also been coded in the 1-hour TF, since the crossover only occur on closed bars with “updateonclose”)
  • manage the stoploss to put it at open price + 5 points if the price has reached at least 15 points of profit (see picture below for a better comprehension)

Order opened at 03:00 (because the RSI crossed the level 50) and the breakeven function put a stoploss at 08:47. Condition are well checked and executed each 1 minute.

Share this