[R-SIG-Finance] Adding vertical line to chart
Joshua Ulrich
josh.m.ulrich at gmail.com
Sat Dec 28 17:54:57 CET 2013
On Sat, Dec 28, 2013 at 7:14 AM, <manojit_roy at comcast.net> wrote:
> I am trying to add a vertical line near the end of a chart plot, using the following code segment:
>
>> getSymbols('GTAT')
>> ticker <- last(GTAT,'3 months')
>> n <- dim(ticker)[1]
>> candleChart(ticker,TA='addLines(v=ticker[n-5])',theme='white',up.col='green',dn.col='red',major.ticks='months',minor.ticks=FALSE,show.grid=FALSE)
>
> Instead of adding a single vertical line at the 5th last bar of the plot, which is what I want, it adds a number of them (3 or 4 or more?) near the beginning. How do I get this to work?
>
It's plotting a vertical line for each column value of ticker[n-5].
'v' needs to be an integer: addLines(v=ticker[n-5,which.i=TRUE])
> Thanks.
> [[alternative HTML version deleted]]
>
Best,
--
Joshua Ulrich | about.me/joshuaulrich
FOSS Trading | www.fosstrading.com
More information about the R-SIG-Finance
mailing list