SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Mon Sep 23, 2019 2:18 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Slow turtle problem
PostPosted: Fri Dec 05, 2008 5:35 pm 
Offline

Joined: Mon Jul 09, 2007 11:33 pm
Posts: 24
Hi,

I have problems with slow turtle OQ example. I am a new user without C# knowledge so perhaps my questions will not be relevant.

1) In the OQ doc, we can read "only trades on Monday". It is not the case when we look at the result, why?

2)How is it possible doing trades only on Monday for example or tuesday. I am interested by this point, because I want to create weekly strategies so as we can not manage weekly bars directly I am using daily bar and I want orders will be executed on Monday .

We already answer to me about managing weekly bars: http://www.smartquant.com/forums/viewtopic.php?t=7131

But using this technique, what is the solution to manage gap created by unusual day where the market is closed?

3)I would like sma is calculated in weekly bars exactly not on an approxiamation due to some day off. For example if you use fastSMALength*7 as in the OQ example, you have a gap when the market is closed one day.
Why 7 is used because it is on the SPY instrument in the example which quotes during 5 days?
And why in the code the Barblocksize is defined at 6?

Regards,

Luxilon


Top
 Profile  
 
 Post subject: Re: Slow turtle problem
PostPosted: Fri Dec 05, 2008 6:06 pm 
Offline

Joined: Fri May 06, 2005 1:40 am
Posts: 521
luxilon wrote:
2)How is it possible doing trades only on Monday for example or tuesday. I am interested by this point, because I want to create weekly strategies so as we can not manage weekly bars directly I am using daily bar and I want orders will be executed on Monday .


A partial answer to your questions: You can use the C# DateTime.DayOfWeek method to determine if your current bar is a Monday:
http://msdn.microsoft.com/en-us/library ... fweek.aspx
http://msdn.microsoft.com/en-us/library/bb762911.aspx


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2008 7:07 pm 
Offline

Joined: Mon Jul 09, 2007 11:33 pm
Posts: 24
Thanks a lot for your help.

Does anyone could help me in completing the answer?


Top
 Profile  
 
 Post subject: Re: Slow turtle problem
PostPosted: Sat Dec 06, 2008 2:50 am 
Offline

Joined: Thu Jun 08, 2006 3:56 pm
Posts: 537
Location: BC Canada
I can answer a few of your questions, but not all of them. I wrote the accompanying doc when I was first learning how to use SQ stuff. One of the SQ guys actually wrote the code, and made some implementation decisions that you are asking about.

Quote:
1) In the OQ doc, we can read "only trades on Monday". It is not the case when we look at the result, why?


The "trades only on Monday" phrase was the phrase used in Altucher's book where he says the slow turtle algorithm was given to him by the manager of a multi-billion dollar hedge fund. So I put it in my doc to explain the code.

To be faithful to the book story, the code should probably trade only on Mondays. But if it does not, I suppose that could be because the code writer aimed for trading every 7 days (or 6 days, given the BarBlockSize number). As Keith said earlier, if you want exact Mondays instead of "every 7 days", you'd have to use the C# method he suggested (thanks Keith).

Quote:
2)How is it possible doing trades only on Monday for example or tuesday. I am interested by this point, because I want to create weekly strategies so as we can not manage weekly bars directly I am using daily bar and I want orders will be executed on Monday .


You can get weekly bars into OnBar, but they won't really help you if want to trade only on Mondays---you'll have to get some kind of signal or bar into your OnBar subroutine on Mondays so you can see if today's bar is a Monday bar. Then you can actually issue orders on the Monday (assuming the market is open.)

Quote:
But using this technique, what is the solution to manage gap created by unusual day where the market is closed?


I don't think this code tries to handle any special real life cases. It just attempts to trade every BarBlockSize = 6 days, and doesn't worry about Mondays. I suppose you could say the code kind of works for GLOBEX currency futures contracts that trade 6 days a week, so 6 could be a chosen number for that reason.

Quote:
3)I would like sma is calculated in weekly bars exactly not on an approxiamation due to some day off. For example if you use fastSMALength*7 as in the OQ example, you have a gap when the market is closed one day.


Agreed on this point. I think the code writer was just trying to express the parameter in weeks, not days, so he multiplies the parameter week value by seven to calculate the length of the moving averages. You can specify the length of the average any way you like, of course.

It probably doesn't really matter to the averages and their crossover points if one or two days of Monday data are missing. For example, a 22 week * 7 days is a 154 day moving average, and a 55wk * 7 is a 385 day average. I'm sure they would cross in more or less the same place if they were a 152 day and 383 average instead.

Quote:
Why 7 is used because it is on the SPY instrument in the example which quotes during 5 days?


I imagine 7 is used because there are 7 days in the week, and you need to multiply the 22 and 55wk parameters by something to convert them to daily average lengths for the SMA indicators. I don't think the 7 is related to the number of days that an instrument trades (although maybe it should be; if you would like to code it that way, just use 22 * 5 and call it a 110-market-data-day average, I guess).

Quote:
And why in the code the Barblocksize is defined at 6?


I have to agree with you here, this confused me when I first saw it too. I would have expected a 7, if the aim was to "trade every seven days (ie, Monday)". I couldn't figure out at the time how Monday was supposed to result from the "if positionInBlock == 0" test either.

Of course now I can see (like you can) that BarBlockSize = 6 means that the strategy will trade every six days, and will only trade on Monday once every 6 or 7 weeks, when 0 from the Modulo operator actually means Monday.

I suppose that it's worthwhile to say that the examples are only examples, and leave out a lot of real life stuff that your strategy should probably handle. Good luck!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 18, 2008 6:34 pm 
Offline

Joined: Mon Jul 09, 2007 11:33 pm
Posts: 24
Thanks a lot for your help kkkwj.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group