The Pairs Trade indicator is a utility for semi-automatic pair trading. It allows combining the charts of two arbitrary instruments, even if the schedules of their trading sessions are different. It displays a spread chart in the form of a histogram with an overlaying moving average. It calculates the swap that will be charged for the synthetic position (in the deposit currency). It is possible to set a level for automatic opening of a synthetic position on the spread chart (analogous to the 'sell limit' pending order). Trading information is displayed on the information panel, which can be dragged using the mouse. The indicator automatically saves all changes.
The indicator can be controlled using hot keys (the indicator window must be in focus - click it). All hot keys, except for F5, are located on the numeric keypad (NumPad).
- Ctrl + . - enable/disable the trade operations;
- 0 - enable/disable the audio signals;
- 1 - mirrored display of the spread histogram;
- Ctrl + 1 – invert the instrument chart;
- 2 - create an Open line;
- 3 - create a Close line, if at least one synthetic position is open;
- 4, 6 - set the number of synthetic positions to be closed at the Close level (from 1 to 7);
- * - show the ratio of lots / vertical shift of the chart;
- /, 8 - increase/decrease the ratio of lots per step / vertical shift of the chart per step;
- 7, 9 - increase/decrease the step value;
- F5 - refresh the trade information and the spread histogram.
Select a pair of highly correlated or anticorrelated instruments, such as WTI-BRENT, GOLD-USDCHF. Open the chart of the first instrument and run the PairsTrade indicator. Specify the symbol of the second instrument in the indicator settings. The second chart will be displayed aligned with the first. Invert the chart of the second instrument, in case the instruments are anticorrelated. Adjust the vertical shift of the second chart and change the ratio of lots so that the spread volatility is maximized in the desired time interval. If the current spread becomes negative, make a mirrored display of the spread histogram.
The current spread is recalculated at every tick of the first instrument's price. Open a chart of the second instrument and run the PairsTrade indicator with the Symbol parameter blank. The current spread will now be recalculated at each tick of the second instrument's price as well. Return to the first chart and run the PairsTradeExec EA. Make sure the EA is allowed to trade, and automatic trading with EAs is allowed in the terminal settings.
Create an Open line and drag it to the level, where a synthetic position is to be opened. The Description field in the properties of this line contains the instrument symbols and the corresponding volumes in lots. If necessary, modify the proposed values, with consideration of the specified ratio between the lots. Enable the trading operations. Once the spread reaches the marked level, a synthetic position will be opened, the information on the opened orders will be displayed in a pop-up window. After that, create a Close line and drag it to the level, where the synthetic position is to be closed.
- Symbol - symbol of the second instrument;
- Maximum number of pictured bars – the maximum number of displayed bars;
- Show moving average – display the moving average;
- Moving average period – period of the moving average;
- Black candle color - color of the bullish candle of the second chart;
- White candle color - color of the bearish candle of the second chart;
- "Bid" line color - color of the Bid line;
- "Ask" line color - color of the Ask line;
- Put InfoPanel into the main window – place the information panel in the main window;
- InfoPanel background color – background color of the information panel;
- InfoPanel text color - text color of the information panel;
- InfoPanel text fontsize – text size of the information panel.
- in the settings, added the selection of the information panel location either in the indicator window or in the main chart window.
- added the info panel in the main chart window. It can be selected and moved within the window. Added ability to select the background and panel text colors;
- added ability to set the maximum number of displayed bars.
Download the updated PairsTradeExec v1.1 EA for correct execution of trading orders.