[R-SIG-Finance] Using quantstrat indicators against columns other than "Close"

Sergey Pisarenko drseergio at gmail.com
Fri Feb 10 18:51:36 CET 2012


Thank you, Brian. This all makes sense now.

/Sergey

On Fri, Feb 10, 2012 at 8:37 AM, Brian G. Peterson <brian at braverock.com> wrote:
> On Fri, 2012-02-10 at 08:26 -0800, Sergey Pisarenko wrote:
>> Hi,
>>
>> I have started using 'quantstrat' to model strategies and cannot
>> figure out a way to add an indicator that would be calculated against
>> a column other than "Close". For example, in the code below I create a
>> 5-day SMA:
>>
>> s         <- add.indicator(strategy=s, name='SMA',
>> arguments=list(x=quote(Cl(mktdata)), n=5), label='SMA5')
>>
>> This creates a column with 5-day SMA calculated for the closing price
>> of the instrument. What is the correct approach of using indicators
>> against other columns, such as "Volume"?
>
> the Cl() function there should be the clue...
>
> Cl(), Op(), Vo(), etc are all utility functions provided by quantmod to
> extract specific columns by common name.  You could also use standard R
> subsetting to get any column you want out of your data.
>
> Regards,
>
>   - Brian
>
> --
> Brian G. Peterson
> http://braverock.com/brian/
> Ph: 773-459-4973
> IM: bgpbraverock
>



More information about the R-SIG-Finance mailing list