[R-SIG-Finance] Signal and Rule question in Quantstrat
Brian G. Peterson
brian at braverock.com
Sun Feb 1 17:41:45 CET 2015
On 02/01/2015 09:12 AM, Mark Knecht wrote:
> (As I read it he's saying 'How to I combine
> multiple indicators into a singlerule?') It's not hard in quantstrat
> to write indicators, and it's not difficult to create a strategy based
> on a single indicator - there are lots of provided examples. However,
> as I remember it from months and months ago (I could be wrong, it
> might have change, I don't know as I haven't looked) it seemed quite
> difficult to turn groups of indicators into executable rules, such as
> his entry rule:
>
> PRICE > SMA=250
> Slow Stochastic < 20 and crossing above the 20 line
>
> so maybe you can point him to something that addresses just that issue.
I think that this may make more sense if restated a bit
Multiple indicators have been defined, let's say that their labels are
set as:
pc.gt.sma250 # for PRICE > SMA=250
stoch.lt.20 # Slow Stochastic < 20
stock.cross.20 # Slow Stochastic crossing above the 20 line
First, I'm not sure how condition Slow Stochastic < 20 and condition
Slow Stochastic crossing above the 20 line can both be true. Let's skip
that for now.
I believe that what you would be looking for is a sigFormula *signal*.
The rule will likely be ruleSignal, as usual.
The formula argument for sigFormula in the above case might be stated:
formula='pc.gt.sma250 && stock.lt.20 && stoch.cross.20'
The rest of the strategy should be pretty straightforward stuff, only
the sigFormula bit seems to confuse people.
If I have time in the next several days, I'll try to create a demo that
does this (or we would gladly accept a demo from someone else that does
this).
Regards,
Brian
--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock
More information about the R-SIG-Finance
mailing list