graftonian 1,089 posts msg #142350 - Ignore graftonian |
2/19/2018 12:38:19 PM
I am tinkering with a sector rotation strategy, and would like to utilize SS for back testing.
The heart of the system would be in the ranking of ETFs in a sector. This would be accomplished in SF, and transferred to SS.
QUESTION:
Does anyone have a clue how to write and entry string that would buy at close on the last day of the month?
The exit string could follow similar logic as the entry string or a $daysheld statement.
Thanks
|
nibor100 1,031 posts msg #142356 - Ignore nibor100 |
2/19/2018 7:01:12 PM
@graftonian,
The thread below from the StrataSearch forum looks like it might have possibilities for what you want to do:
"Reference to condition
Postby Schutten » Tue Feb 01, 2011 4:50 pm
I have the following condition.
Only buy long: dayofmonth()=1 and close>period(monthly,mov(close,10,simple)
With other words on day 1 of the month this value is calculated. Now I want to program that the rest of the month the system can only buy long without recalulating if the condition is still true.
How do I do this?
If it can recaculate multiple times per month I can have a lot of zigzag movements and this is something I don't want.
Regards,Dennis Schutten
Re: Reference to condition
Postby Overload » Tue Feb 01, 2011 5:30 pm
You probably don't want to use DayOfMonth()=1 since the first day of the month might not be a trading day. Instead, I would test whether "today's" month is different from "yesterday's" month. That would look like this:
month() <> ref(month(), -1)
I would then put that in the ValueWhen() formula to identify the close price on the first day of the month:
ValueWhen(month() <> ref(month(), -1), close)
Finally, you can create your filter to make trades only in months where the close price on the first day is higher than the 10-month moving average:
ValueWhen(month() <> ref(month(), -1), close) > period(MONTHLY, mov(close, 10, simple))"
Otherwise the Stratasearch 'Period' command might be of use....
If you haven't already found and tried them,
Ed S.
|