[R-SIG-Finance] Bollinger Bands error

Joshua Ulrich josh.m.ulrich at gmail.com
Sat Oct 30 18:37:16 CEST 2010


Hi Nikos,

On Sat, Oct 23, 2010 at 4:25 PM, Nikos Rachmanis
<nikos.rachmanis at gmail.com> wrote:
> Hi Joshua & Jeff,
> Thank you very much for your answers. As you said I followed you
> recommendation with the following code:
> Close<-as.matrix(close)
> BB<-format(BBands(Close, n=14, sd=2), digits=6)
> Joshua, the only thing that I do not comprehend fully is the maType argument
> you have. How exactly do you use it?

The maType argument isn't particularly interesting in BBands because
BBands only requires one MA.  maType allows you to specify different
MAs (or the same MA with different arguments) for functions that have
more than one MA.  ?RSI has some examples:

# Case of one 'maType' for both MAs
rsiMA1 <- RSI(price, n=14, maType="WMA", wts=ttrc[,"Volume"])

# Case of two different 'maType's for both MAs
rsiMA2 <- RSI(price, n=14, maType=list(maUp=list(EMA,ratio=1/5),
              maDown=list(WMA,wts=1:10)))


> Thank you very much everyone for the very useful feedback,
> Nikos

Best,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com


> On Thu, Oct 21, 2010 at 6:01 PM, Joshua Ulrich <josh.m.ulrich at gmail.com>
> wrote:
>>
>> Hi Nikos,
>>
>> On Thu, Oct 21, 2010 at 4:37 PM, Nikos Rachmanis
>> <nikos.rachmanis at gmail.com> wrote:
>> > Hi all,
>> >
>> > I am new to R and I would appreciate if someone can help me out with the
>> > following problem. I am trying to use the TTR package in order to
>> > calculate
>> > the Bollinger Bands. I have created a matrix with the Open, High, Low
>> > and
>> > Close variables using the following command:
>> >
>> You did not create a matrix, you created a data.frame.  They are
>> different.  Compare ?data.frame and ?matrix.
>>
>> > OHLC<-data.frame(open, high, low, close, check.names=TRUE)
>> >
>> > However every time I am trying to run the command ( BBands(OHLC, n=20,
>> > maType, sd=2, ...)) this is the error I am getting:
>> >
>> > "Error in inherits(x, "xts") : object 'x' not found"
>> >
>> A reproducible example would help.  Even if you did not get the above
>> error, your command should fail because the OHLC object has 4 columns
>> and BBands only accepts objects with 1 or 3 columns (see ?BBands).
>>
>> > Has anyone came across this problem in order to know the solution?
>> >
>> > Thanks a lot in advance,
>> > Nikos
>> >
>> >        [[alternative HTML version deleted]]
>> >
>> > _______________________________________________
>> > R-SIG-Finance at stat.math.ethz.ch mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> > -- Subscriber-posting only. If you want to post, subscribe first.
>> > -- Also note that this is not the r-help list where general R questions
>> > should go.
>> >
>
>



More information about the R-SIG-Finance mailing list