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!