Spread and Pair Trading

From MultiCharts
Jump to: navigation, search

Exchange Traded Spreads

In MultiCharts one is able to trade on a spread only if it is exchange traded spread and it is provided by your data vendor as a single separate instrument that is added to QuoteManager database (see Adding Symbols to Database) and mapped correctly to the corresponding broker instrument in Symbol Mapping window. If there is no such instrument on data source end and at your broker, then it is not possible to trade such spread.

Visual Spread on Chart

To see a spread histogram of 2 instruments, one needs to plot a chart window with 2 symbols as data series 1 and data series 2. In the list of our prebuilt studies there are 2 spread indicators that can be applied to such chart: Spread - Diff and Spread - Ratio. See the following article on how to use studies in MultiCharts. The default studies can be modified to plot the spread you need, e.g. using the PlotPaintBar keyword to create OHLC bars.

Pair Trading in Real-Time

One can only send orders to buy or sell one or another instrument of a pair in MultiCharts, but to reach this goal the following system should be developed:

  • 2 separate chart windows should be plotted with both symbols of a pair on the charts.
  • On the first chart the symbol A should be plotted on subchart 1. The symbol B should be plotted on subchart 2.
  • On the second chart the symbol B should be plotted on subchart 1. The symbol A should be plotted on subchart 2.
  • On both charts the strategies that have similar but reversed logic should be applied to buy for the 1st chart and to sell for the 2nd one (orders can be placed only on data series 1).
Example: When one of the pair is bought or sold, your strategy needs to know exactly what’s going on with both symbols. If your pair is Google and Microsoft, you would enter GOOG as symbol one and MSFT as symbol two on first chart. Then you would add MSFT as data one and GOOG as data two on second chart. On first chart when a condition on data 1 is met the strategy buys and at the same time when this very condition is met on the second data series of the second chart that strategy sells and vice versa. This way each instrument in the pair is actively referencing the other instrument—and you achieve complete synchronization.


There is also another, a more complex way to pair trade:

  • 2 separate chart windows should be plotted. 1 symbol of a pair per chart.
  • 2 separate signals should be applied to each of the charts.
  • Each signal script should use Global Variables in its script to pass values between the charts.
Example: When on first chart a particular condition for order generation is met and the strategy sends a market order to go 1 contract long, through Global Variables this strategy informs the other signal on the second chart to generate a market order to go 1 contract short.

Pair Trading in MultiCharts .NET in Real-Time

In MultiCharts .NET it is possible to send one order to different symbols/accounts/brokers at same time without Global Variables in real-time trading.

Pair Trading in Backtesting

It is not possible to use Global Variables for backtesting of your pair-trading strategy either in regular MultiCharts, or in MultiCharts .NET. However it is possible for both products in Portfolio Trader by means of Global Variables. Multiple data series should be allocated in correct order in Portfolio Trader, so it is possible to perform pair trading, using GV, because of vertical bar-by-bar calculation of the strategy on all of your data series.

Example: When you have GV on first series, you should be able to get those GV when script is calculated on next data series. The calculation of the script is sequential. It means that the script is first calculated on bar 1 of data A and it generates a sell order (as an example) and passes a value through global variable. Then the script is calculated on bar 1 of data B where it reads the global variable and generates identical buy order. Though everything happens sequentially, in fact the sell and buy orders are generated on the bars with the same timestamp (if data A and data B have identical series).