Seasonality in Strategies


Category:
0
0

Hi Pete,

Do you know if there is a way to add a date range to a strategy for execution of orders and backtesting?

Example: Oil goes up every year sometime between January 1 and February 15th.

I would like to have this date range as part of a strategy so if it is between January 1 and February 15th then execute if any or all other parameters are satisfied (e.g., first moving average crossover during this time period).

Additionally, when I back test I would like to back test for the same date range but different years to test performance over time.

Thanks for the help!

Justin

 

Marked as spam
Posted by (Questions: 8, Answers: 10)
Asked on January 27, 2020 2:10 pm
97 views
0
Private answer

You didn't provide any code whatsoever so I take this to mean you simply want some guidance not a complete solution.

I have pondered several potential solutions to this. Having reached my time limit for free solutions in the Q&A forum I will say that a quick and easy solution did not come to me. We have functions in the Thinkorswim language that count the number of days until or from a specified date. However those will not do the job because you would need to enter a complete date, including the year and immediately we fail because you want this code to work for any number of previous years.

So we have some functions in Thinkorswim that let us get the day of month or the month for a given bar. However how do you then take those functions to create a target date range? There is no simple way to do so. This potential solution is complicated by the fact that any day or month we select as the input must be a day of the week the markets were open for trade. Otherwise the code fails.

So some other method must be employed to overcome this limitation. Or perhaps we need a completely different approach all together.

Bottom line is, the solution is far more complex than anything I can provide free of charge in the Q&A forum.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on January 27, 2020 2:40 pm
0
Thanks Pete. What is the best way to transition this into a paid project and get a quote?
( at January 28, 2020 8:00 am)
0
All the details are listed on the following page: https://www.hahn-tech.com/about/
( at January 28, 2020 8:32 am)