Available translations

Time Frame

foundations.png
time-frame.png
The time frame determines the collection of candles to be analyzed during a backtesting session, and the frequency with which the trading bot runs on paper trading, forward testing, and live trading sessions.
Content
In Live Sessions
In the context of live sessions, that is, paper trading, forward testing, and live trading, you may want to run the session on the 01-min time frame so that the trading bot reacts fast when the price tags the take profit or stop loss targets.
If for whatever reason you don't need to minimize the potential for slippage when hitting stop or take profit targets, you may choose whatever time frame you like, taking into account the explanations below.
In Backtesting Sessions
In the context of backtesting sessions, what time frame you decide to run the session depends on the trading system being tested. If the trading system makes decisions based on the 1-hour candle and above, then 01-hs may be the best choice. However, if decisions are influenced by sub-hour candles then you should match the time frame accordingly.
In other words, in backtesting sessions, you should match the time frame to the smallest period on which the trading system makes decisions.
Remember what was said about stop loss and take profit orders earlier: they do not exist in Superalgos. When a target is hit, orders are placed in the following Cycle, which happens to be on the next candle!
Let's take a minute to reflect on the implications of the above! If targets are hit on one candle and orders are placed on the next candle, there is the potential for huge Slippage if the session is run on higher time frames! This is the cost in precision mentioned earlier.
The above explanation seems to point in the following direction: if you want backtesting simulations to be comparable to live sessions run on the 01-min time frame, then you should run the backtesting session on the 01-min time frame as well. There is, however, a workaround.
Workaround
You may use the Simulated Exchange Events structure of nodes to arbitrarily define the exit rate of the position.
For example, you may use the following formula in the Simulated Actual Rate node as well as in the Target Rate of the Close Stage:
 targetRate()

function targetRate() {
    switch (tradingEngine.tradingCurrent.position.exitType.value) {
        case 'No Exit': {
            return tradingEngine.tradingCurrent.tradingEpisode.candle.close.value
            break
        }
        case 'Take Profit': {
            return tradingEngine.tradingCurrent.position.takeProfit.finalValue.value
            break
        }
        case 'Stop Loss': {
            return tradingEngine.tradingCurrent.position.stopLoss.finalValue.value
            break
        }
    }
}
The formula sets the Simulated Actual Rate to be the last known takeProfit rate if the exit was triggered by hitting of the Managed Take Profit, or the last known stopLoss in case it was the Managed Stop Loss target.
Why the Time Frame Matters
Running trading sessions of any given trading system on different time frames may produce different results. This is because the behavior of a trading session may vary depending on how well the time frame matches the logic of the strategy.
The trading bot evaluates closed candles only. At any given point in time, the current candle in each time frame is the candle that closed last.
For example, let's say it's 11 hours, 39 minutes and 30 seconds of June 11th, 2020. This is how the system determines which is the current candle:
  • 1-minute candle: it is the one that closed at 11:38:59.999.
  • 5-minute candle: it is the one that closed at 11:34:59.999.
  • 30-minute candle: it is the one that closed at 11:29:59.999.
  • 1-hour candle: it is the one that closed at 10:59:59.999.
  • 2-hour candle: it is the one that closed at 09:59:59.999.
  • 6-hour candle: it is the one that closed at 05:59:59.999.
  • 24-hour candle: it is the one that closed at 23:59:59.999 of June 10th!
Let's say the trading system implements conditions that evaluate 30-minute and 1-hour candles.
If a session is run at the 30-minutes time frame, all 30-minutes candles are evaluated. Also, all 1-hour candles are evaluated twice.
However, if the session is run at the 1-hour time frame, only one out of two 30-minute candles are evaluated.
And if the session is run at the 2-hour time frame, only one out of four 30-minute candles and one out of two 1-hour candles are evaluated.
This means that running the session (for this particular trading system) at the 30-minute time frame has higher probabilities of conditions evaluating 30-minute candles to be true during the session.
In other words, when running the session on time frames higher than the time frame on which decisions are made, chances are the bot will eventually skip candles on which conditions would have evaluated true, potentially skipping trading opportunities.
The above is true for all types of trading sessions.
Configuring
Time Frame Configuration
Properties
  • value is the setting for the time frame. You may use any of the values below.
 01-min
02-min
03-min
04-min
05-min
10-min
15-min
20-min
30-min
45-min
Available options at larger time frames are:
 01-hs
02-hs
03-hs
04-hs
06-hs
08-hs
12-hs
24-hs
Initial Values
These are the Initial Values for Time Frame configuration:
 {
    "label": "01-hs"
}
Examples
This is a list of properties featured by the Time Frame configuration. Expanding a property shows sample values for the property extracted from the current Workspace.
Time Frame Menu
The Time Frame node has the following Node Menu items:
The Configure menu item has the following properties:
  • action: Configure
  • label: Configure
  • iconPathOn: configuration
  • iconPathOff: configuration
  • actionFunction: uiObject.configEditor.activate
The Delete menu item has the following properties:
  • action: Delete UI Object
  • actionProject: Visual-Scripting
  • askConfirmation: true
  • confirmationLabel: Confirm to Delete
  • label: Delete
  • iconPathOn: delete-entity
  • iconPathOff: delete-entity
  • actionFunction: payload.executeAction
Time Frame Attaching Rules
The following are the Node Attaching Rules that govern the attachment of Time Frame with other nodes:
Compatible Types: