Algo - Pairs Trading (Indicator)

Disclaimer

  Input Information

Name Type Default Description
Enabled Numeric 0 Set to 1 for indicator to place orders, otherwise 0.
AccountNumber String (enter acct) Set to your equities trading account.
DollarsPerTradeSymbol Numeric 1000 Dollars per trade per symbol.
LongEntryCond TrueFalse

(see input)

Conditions for a "Long the Spread" position (see code for input parameters)
ShortEntryCond TrueFalse (see input) Conditions for a "Long the Spread" position (see code for input parameters)
LongCondPlotPrice Numeric Low Price to plot dot marker when long entry condition occurs.
ShortCondPlotPrice Numeric High Price to plot dot marker when short entry condition occurs.
PaintFirstRTBar Numeric 1 Set to 1 to have first real-time bar painted with RTBarColor, otherwise 0.
RTBarColor Numeric Yellow Color for painting the first real-time bar. This will override any color set in the Customize Indicator dialog.

Market Synopsis

The Algo - Pairs Trading indicator is designed to trade a pair of symbols (a spread) from a Chart that contains both symbols, inserted into the chart as Data1 and Data2.  This indicator is designed to work with liquid symbols that have bars at each bar interval in both data streams (no missing bars due to illiquidity).

 

This indicator is designed to work only with equities.

 

A "Long the Spread" position is long the symbol in Data1 and short the symbol in Data2.  A "Short the Spread" position is Short the Symbol in Data1 and Long the symbol in Data2.   The bar intervals of Data1 and Data2 must be the same.

 

Dot markers are plotted when "LongEntryCond" and "ShortEntryCond" are true.   When "LongEntryCond" is true, a bright marker (colored cyan, by default) is plotted below the bar.  A dark marker (dark cyan, by default) identifies a long condition that will not generate entries because the last entry signal was long (no pyramiding is allowed - see item 5, below).  Likewise, a bright marker (colored magenta, by default) is plotted above the bar for a short condition ("ShortEntryCond" is true) and a dark marker (dark magenta, by default) is used to identify a short signal that will not generate a short entry because the last signal was a short signal. Dots for the first entry in real-time will be brightly colored (cyan or magenta, by default) regardless of the color of the prior dot. Thus, if the code is running in real-time, a bright, not dark, dot means an entry should be placed.  If no entry is triggered, troubleshooting by the user is required.  

 It is recommended that you first use this indicator with simulated accounts to become familiar with its order placement behavior.

Plot Information

None

Related Classes

OrderTicket, PositionsProvider, OrdersProvider, AccountsProvider

Related Topic

Creating a Multi-Data Chart