Reference to condition

StrataSearch will find what you tell it to, but what should that be? Will the same criteria work across different Sectors? Different time periods? Here we discuss the ins and outs of OneClick Searches.

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.

Posts: 42
Joined: Thu Oct 25, 2007 6:17 am

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))

I think that should do it.

Posts: 2248
Joined: Wed Nov 30, 2005 12:14 pm

Return to OneClick Searches and Scoring