Backtesting a list of end-to-end periods

Questions about MultiCharts and user contributed studies.
systemicrisk
Posts: 4
Joined: 02 Nov 2011
Has thanked: 2 times

Backtesting a list of end-to-end periods

Postby systemicrisk » 24 Jan 2012

Hello,

I have a number of daily strategies that I've created in excel.

I would like to use these daily strategies as a time & direction filter for backtesting various strategies intraday.

An example:
long on open 1st January
cut & reverse short on open 5th January
exit on open 10th January
Short 15th January
Exit 20th January

I would then like to test an intraday strategy where it checks the above dates for whether a trade is allowed, and the direction. Hence it can only go long from the 1st - 5th, short from the 5th - 10th, no trades allowed from 10th - 14th, short only from 15th - 19th.

Is there a simple way that I can load in a list of dates and use them as a filter for a) whether a trade is allowed (within the daily end-to-end trade period) and b) the trading direction allowed.

Thanks

SR

User avatar
furytrader
Posts: 353
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 215 times

Re: Backtesting a list of end-to-end periods

Postby furytrader » 25 Jan 2012

Hi SR,

This shouldn't be too hard to implement. All you have to do is set up a few tracking variables and analyze each date to see if it falls within the areas in which you want to be long or short. Based upon that analysis, you can flag whether it's okay to go long, or short, etc.

Here's how I would do it:

Code: Select all

Variables: OkayToGoLong(FALSE), OkayToGoShort(FALSE);

OkayToGoLong = FALSE;
OkayToGoShort = FALSE;

If Month(Date) = 1 and (DayOfMonth(Date) <= 4) Then Begin
   OkayToGoLong = TRUE;
   OkayToGoShort = FALSE;
End;

If Month(Date) = 1 and (DayofMonth(Date) > 4 and DayOfMonth(Date) <= 9) Then Begin
   OkayToGoLong = FALSE;
   OkayToGoShort = TRUE;
End;

{Apparently no trading is allowed between January 10th and the 14th}

If Month(Date) = 1 and (DayOfMonth(Date) >= 15 and DayOfMonth(Date) <= 20) Then Begin
    OkayToGoLong = FALSE;
    OkayToGoShort = TRUE;
End;

{For that last filter, it wasn't clear that when you say "Exit 20th January", whether you meant at the close of January 20th or at the open - the code above assumes it's at the close of January 20th with the "<=" comparison. If you meant exit at the open of January 20th, I would change "<=" to "<" }

{Enter in the code for your intraday strategies here}



You would then use the values of OkayToGoLong and OkayToGoShort to determine whether to take long or short trades based upon your intraday strategies.

Hope this helps - good luck!
These users thanked the author furytrader for the post (total 3):
TJsystemicriskJoshM


Return to “MultiCharts”