Pair trading bactest

Questions about MultiCharts and user contributed studies.
TomMC
Posts: 6
Joined: 29 Aug 2016

Pair trading bactest

Postby TomMC » 29 Aug 2016

Hello,
I m trying to perform the below strategy:

CF Wiki -----------------------
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 plotted on subchart 1. The symbol B should be plotted on subchart 2.
On the second chart the symbol B should plotted on subchart 1. The symbol A should be plotted on subchart 2.
On both charts the strategies should be applied that has similar but reversed logic to buy for 1st chart and to sell 2nd one (orders can be placed only on data series 1).
--------------------

All the above seems to work.
However, would like to close the position based on the P&L resulting from both position.
Apparently Openprofitposition works for a strategy only
Portfolio_openprofitposition seems to doesn't worl too.

How can I backtest this kind of strategy in the portfolio manager, and close position based on the Profit or loss resulting from Strategy A instrument A with Strategy B instrument B ?

Many thanks

TomMC
Posts: 6
Joined: 29 Aug 2016

Re: Pair trading bactest

Postby TomMC » 30 Aug 2016

Hi,

Nobody can help?

please let me know if I need to clarify.

thank you

TomMC
Posts: 6
Joined: 29 Aug 2016

Re:Portfiolio Pair trading bactest

Postby TomMC » 01 Sep 2016

Hello,

No answer and that s quite unsual ! So if I may insist. Support any help is possible ?
No one try to perform such strategy throught the portfolio backtester ?

Thank you

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Re:Portfiolio Pair trading bactest

Postby TJ » 01 Sep 2016

Hello,

No answer and that s quite unsual ! So if I may insist. Support any help is possible ?
No one try to perform such strategy throught the portfolio backtester ?

Thank you
What symbols are you trying to trade?
Are they of similar volume and activities?

What is the chart resolution?

Can you give it some detail?

TomMC
Posts: 6
Joined: 29 Aug 2016

Re: Pair trading bactest

Postby TomMC » 01 Sep 2016

Hi TJ
Of course with a great pleasure !

I'm using USD/JPY with EUR/JPY all in 30 Minutes

So as an exemple close of data1 as EUR/JPY
Strategy 1
If close of data1 is > MM20 and close of data2 < MM20 then buy 10 contracts next bar at market;
If close of data1 is < MM20 and close of data2 > MM20 then sellshort 10 contracts next bar at market;

Strategy 2
close of data 1 as USD/JPY
If close of data1 is > MM20 and close of data2 < MM20 then Sellshort 10 contracts next bar at market;
If close of data1 is < MM20 and close of data2 > MM20 then buy buy 10 contracts next bar at market;

The strategy seems to work as I can see the open position buy and short at the same time for both instrument.

But how to close position based on the Pnl resulting from both position?
thanks

TomMC
Posts: 6
Joined: 29 Aug 2016

Re: Pair trading bactest

Postby TomMC » 02 Sep 2016

Hi TJ,
No idea ?

Can you please at least confirm that Portfolio_Openpositionprofit return the curent position resulting from all positions open in a portfolio, in prod and backtest ?

Thanks

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Pair trading bactest

Postby TJ » 02 Sep 2016

Hi TJ,
No idea ?
I have no idea.
There is not much more I can offer with the limited information.

Maybe other users can help.

Have you read the Pairs Trading articles in the Wiki?

Can you please at least confirm that Portfolio_Openpositionprofit return the curent position resulting from all positions open in a portfolio, in prod and backtest ?

Thanks
Have you read the keyword definition in the Wiki?
It should have the explanation and usage example you need.


Please note that this calculation is performed at EOB (End Of Bar).

TomMC
Posts: 6
Joined: 29 Aug 2016

Re: Pair trading bactest

Postby TomMC » 02 Sep 2016

I'm not sure to understand what other information are needed.
I red all possible things before to ask help from support.

The below is an example but both strategy works inependently in the classical backtest, as expected (exept that the exit condition can't be done as I'm trying to close position if position A + position B = X profit or loss). In classique mode, I can see that position buy on instrument A is opened at the same time that a short in instrument B.

I can see that openposition profit works when I test one of the strategy in the classique mode.

In the wiki, portfolio_openpositionprofit seems to do what I need (I.E take into account the open position of all strategy)

I will check again the code, but the only difference between the classique backtest mode and the portfolio backtest mode is the portfolio_openpositionprofit vs openpositionprofit.

regarding the pair trading on the wiki what is not clear is the difference between real mode and backtest mode. Is it saying that for the backtest we must use global variable ?

When you say the calculation is performed at the EOD, if I use all Instrument data1 and data2 with same time frame same configuration (24/5, trade volume.. etc). I don't understand why the position is not close at the same time for both strategy :/


Return to “MultiCharts”