Author Topic: Entry / Exit rules  (Read 14562 times)

damiano

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Entry / Exit rules
« on: July 23, 2013, 02:07:57 pm »
Hello,

I am seeing many backtests on your website, and I would like to know how you calculate the entry/exit of the trades.
I see a big list of operations (example: https://www.pairtradinglab.com/backtests/Ue6COpUMoBh7YGm1)

What do you see (maybe z-score?) to open new positions?

Thank you!

admin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 338
  • Karma: +13/-0
    • Pair Trading Lab
Re: Entry / Exit rules
« Reply #1 on: July 25, 2013, 05:55:06 am »
Yes, Z-Score is used to generate entry/exit signals:
  • if Z-Score crosses the Entry Threshold value (positive), we open short pair position
  • if Z-Score crosses the Entry Threshold value (negative), we open long pair position
  • (for existing position) if Z-Score crosses the Exit Threshold value, we close the pair position

You can choose entry and exit thresholds in the backtest parameters. Default values are:
  • entry threshold = 2.0
  • exit threshold = 0.0

Try to experiment with these settings.

damiano

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Entry / Exit rules
« Reply #2 on: July 25, 2013, 06:43:23 am »
Hi!
thank you for your fast reply.

Ok, but in your backtest how many periods (days) do you use to calculate the second deviation  ?

Because I see a lot of operation so i do not think a very big period. no?

admin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 338
  • Karma: +13/-0
    • Pair Trading Lab
Re: Entry / Exit rules
« Reply #3 on: July 25, 2013, 07:32:32 am »
I assume you mean standard deviation. You can set it yourself, parameter name is "StdDev Period:", default is 15.

damiano

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Entry / Exit rules
« Reply #4 on: July 25, 2013, 09:29:36 am »
so if the ratio is above/below the second deviation (+2 or -2) you will execute the trade, right?

Do you think 15 days are enough? maybe the correlation could be broken in these few days, no?


admin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 338
  • Karma: +13/-0
    • Pair Trading Lab
Re: Entry / Exit rules
« Reply #5 on: July 25, 2013, 12:37:36 pm »
Quote
so if the ratio is above/below the second deviation (+2 or -2) you will execute the trade, right?

right!

Quote
Do you think 15 days are enough? maybe the correlation could be broken in these few days, no?

It depends. For some pairs 15 days is fine, for others it may be not. Personally I prefer pairs which give positive results for all reliable settings. You may want to try the Study feature which executes backtests for many period settings at the same time.

damiano

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Entry / Exit rules
« Reply #6 on: July 25, 2013, 04:01:01 pm »
Perfect! I did this backtest: https://www.pairtradinglab.com/backtests/UfGCZ-moDaRIDuDp

I would like to know how do you calculate the "Thresholds + Delta", because I saw you use it to do the entries.

As you can see there is only one entry in the 2008. (please do not pay attention to the pair, it is only a test)

Looking at the chart I noticed when the black line break the -2 deviation the entry was made. Ok, if it is true, I did not understand what you said before.

I read that you do the entry applying the standard deviation to the ratio. In the Thresholds + Delta what is the black line? it does not seem the ratio. How do you calculate it?

Thank you for the clarification.

admin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 338
  • Karma: +13/-0
    • Pair Trading Lab
Re: Entry / Exit rules
« Reply #7 on: July 26, 2013, 04:51:50 am »
Yes, I admit it is a bit confusing in this chart (it is old and will be updated in future):

Delta = spread = (R-MA)
Thresholds (green "band") = Entry and Exit thresholds multiplied by StdDev

From the mathematical point of view it is equivalent here to work with Z-Score and constant threshold or with Delta (spread) and thresholds multiplied by StdDev...it is just a different graphical representation of the problem.

So yes, the trade was opened because the spread crossed the -2 deviation point. That's mathematically the same, as if the Z-Score crossed the -2 line.

The chart for ratio model backtests will be updated in future also to show the Z-Score too (same way as the chart for Residual model, which already shows the Z-Score graph).