Testing for gaps in pairs trading / external symbol
Author: wmrgrove
Creation Date: 4/23/2018 7:26 PM
profile picture

wmrgrove

#1
My questions is related to back-testing for gaps, in both stocks of a Pairs Trading Strategy?

The code below I believe functions properly but I suspect a more elegant or simple method may exist? Here i am filtering all gaps over 3% in either the Pair "Mate symbol" or the "External symbol" on the entry bar and the prior bar.

Any help is appreciated;

CODE:
Please log in to see this code.


Many thanks to Eugene and "superticker" contributor on this forum for all the help to date!!
profile picture

Eugene

#2
Bill, you could create a simple method that returns a boolean, passing it a Bars object to operate on (e.g. external or the primary Bars) depending on context.
profile picture

wmrgrove

#3
Eugene, could you give me a little more of an example please?
profile picture

Eugene

#4
Something like this (on-the-fly coding, untested) - place on top of (or after) your protected override void Execute():
CODE:
Please log in to see this code.


Consequently, you call it like this:
CODE:
Please log in to see this code.


For the external symbol, substitute "Bars" with your "external":
CODE:
Please log in to see this code.


I hope this is very much clear now.

P.S. If not for the gap percent you could check for isGap on a given bar (found in C.Components): Bar Patterns. Its another limitation is lack of support for external symbol.
profile picture

wmrgrove

#5
Thanks Eugene, got it!
profile picture

Eugene

#6
Any time.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).