Setup a Strategy

Overview

Portfolio Strategy is a collection of scripts that determine when to buy or sell an instrument. A Portfolio Strategy contains the following parts:

  • Trading Strategy - a script that determines when to buy or sell the instrument
  • Position Sizing Script - an optional script that overrides the quantity selected by the Trading Strategy
  • Data Series - the data that the strategy uses as input: e.g., End-of-Day bars
  • Symbols - which symbols the strategy trades
The easiest way to get started is to load one of the system portfolios and modify it. In this guide we use the system portfolio "Backtest Bollinger Bands Support / Resistance" as an example.

On this page:

Portfolio Strategy Wizard

To edit a strategy, double-click on it in the Portfolio Strategies table. This opens the Portfolio Strategy Wizard.

Strategy Settings


Strategy Name - the name of the strategy

Initial Funding - how much money to start the simulation with

Trading Strategy - the script that determines when to buy or sell the instrument

Position Sizing - an optional script that overrides the quantity selected by the Trading Strategy

Chart Template - used when auto-creating a Chart for each symbol in the strategy

The two scripts (Trading Strategy and Position Sizing) often have many parameters. Click on the Edit Parameters button () to edit these parameters. Click on the Open Script button () to open the scripts in the Script Editor, where you can modify them.

Data Series

Select the data that the strategy runs on.

Symbols

Select the symbols that the strategy trades.

Trading Strategy

The Trading Strategy is a script that contains the main trading algorithm. All of the other parts (shown above) exist in support of this script.

The Trading Strategy script usually has many parameters. For example, these are the parameters of the trading strategy used in this example:

Here's an explanation for a few of these parameters. Although these parameters are specific to this example, similar principles are used in many other trading strategies:

  • indicator - an Indicator that is used to generate trading signals. Here, the Bar Close (CLOSE) indicator is used.
  • supportIndicator - a Support Indicator that is used to generate trading signals. Here, a complex indicator is used; see below for details.
  • resistanceIndicator - similar to the Support Indicator

Nested Parameters

Some of the parameters use nested parameters. This means that a parameter has its own, internal parameters. For example:

  • Full parameter name: BBL(CLOSE,20,2)
    • Level 1 parameter: BBL
      • Level 2 parameters: CLOSE, 20, 2

This parameter means: create a Bollinger Bands Lower (BBL) indicator; which uses an underlying indicator of type Bar Close (CLOSE); with periods=20 and factor=2.

You can easily edit these complex parameters by moving into and out of nested parameters. When you click on a nested parameter a new control appears, that allows you to move into the nested parameter:

If you click on the Right Arrow then the list of parameters in the dialog changes to show the nested parameters of the selected parameter:

You can change these parameters, and then click on the Left Arrow to return to the top-level list of parameters.

Optimization

Most of these parameters can be fine-tuned in the Optimization phase of developing a trading strategy. So the initial values that you set here are just a starting point. After Optimization, these parameters will be changed to the best values that were discovered.