R and Metatrader

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

R and Metatrader

yoda55
Hi,

Has anyone ever tried to connect R to MetaTrader (MT4 or MT5)?
I mean by this: get a feed from MT into R, generates the signals in R, send the orders back into MT and get some feedback MT.
I haven't tried it yet and I just want to see if someone  has any experience with this before embarking myself into it.

Any help appreciated.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: R and Metatrader

jondollar
I would be interested also in interfacing R and Metratrader.

I've already made similar interface with Matlab.

I see two possibilities :

- through a database : interface as MySQL DLL for MT4
- through a socket on the local address 127.0.0.0

I think that the second choice will be faster but there we need to define message structure for data exchange, while the database tables are easy to build, using timestamp as primary key

Using the database also provides easy management of historical data.

Are you looking for work at tick level or timeframe ?

I would not use the DDE server to get quotes from MT4 as it allows only one way, so that R could not send data to MT4.

I'm new to R, so I would need to dig in, but I'm very interested to access the nice stats libraries,

and contribute to such nice project ..

Rgds.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: R and Metatrader

Daniel Cegiełka
http://mt4tools.svn.sourceforge.net/viewvc/mt4tools/

regards,
daniel


2010/6/21 jondollar <[hidden email]>:

>
> I would be interested also in interfacing R and Metratrader.
>
> I've already made similar interface with Matlab.
>
> I see two possibilities :
>
> - through a database : interface as MySQL DLL for MT4
> - through a socket on the local address 127.0.0.0
>
> I think that the second choice will be faster but there we need to define
> message structure for data exchange, while the database tables are easy to
> build, using timestamp as primary key
>
> Using the database also provides easy management of historical data.
>
> Are you looking for work at tick level or timeframe ?
>
> I would not use the DDE server to get quotes from MT4 as it allows only one
> way, so that R could not send data to MT4.
>
> I'm new to R, so I would need to dig in, but I'm very interested to access
> the nice stats libraries,
>
> and contribute to such nice project ..
>
> Rgds.
> --
> View this message in context: http://r.789695.n4.nabble.com/R-and-Metatrader-tp1693168p2262676.html
> Sent from the Rmetrics mailing list archive at Nabble.com.
>
> _______________________________________________
> [hidden email] 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.
>

_______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: R and Metatrader

Daniel Cegiełka
W dniu 22 czerwca 2010 10:39 użytkownik Gentil Homme
<[hidden email]> napisał:
> Hello Daniel,
>
> Thanks a lot.
> Very interesting !
> I'll try to compile it on V C++ 2008 Express E.
>
> Do you have experience with it ?

No, I work with linux, so MT4 isn't what I prefer.

It should be easy to work witch R and MT4 via socket. You can use
socketConnection(), readBin(), writeBin() functions. Time-series
objects from messages you can build with XTS package and endpoints()
function.

Some high quality code for broker connection you can find in IBrokers package.

http://r-forge.r-project.org/projects/xts/

http://code.google.com/p/ibrokers/

and for strategy you must to test blotter package:

https://r-forge.r-project.org/projects/blotter/

regards,
daniel


>
> Rgds,
>
> Pierre
>
>
> 2010/6/22 Daniel Cegiełka <[hidden email]>
>>
>> http://mt4tools.svn.sourceforge.net/viewvc/mt4tools/
>>
>> regards,
>> daniel
>>
>>
>> 2010/6/21 jondollar <[hidden email]>:
>> >
>> > I would be interested also in interfacing R and Metratrader.
>> >
>> > I've already made similar interface with Matlab.
>> >
>> > I see two possibilities :
>> >
>> > - through a database : interface as MySQL DLL for MT4
>> > - through a socket on the local address 127.0.0.0
>> >
>> > I think that the second choice will be faster but there we need to
>> > define
>> > message structure for data exchange, while the database tables are easy
>> > to
>> > build, using timestamp as primary key
>> >
>> > Using the database also provides easy management of historical data.
>> >
>> > Are you looking for work at tick level or timeframe ?
>> >
>> > I would not use the DDE server to get quotes from MT4 as it allows only
>> > one
>> > way, so that R could not send data to MT4.
>> >
>> > I'm new to R, so I would need to dig in, but I'm very interested to
>> > access
>> > the nice stats libraries,
>> >
>> > and contribute to such nice project ..
>> >
>> > Rgds.
>> > --
>> > View this message in context:
>> > http://r.789695.n4.nabble.com/R-and-Metatrader-tp1693168p2262676.html
>> > Sent from the Rmetrics mailing list archive at Nabble.com.
>> >
>> > _______________________________________________
>> > [hidden email] 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.
>> >
>
>

_______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: R and Metatrader

yoda55
Thanks everyone for the usefull insigths.
I actually decided to change the way I do things. Research & Optimization stay in R and only the final product get coded in MT4. It makes my life easier
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: R and Metatrader

Johnson, Cedrick W.
Just looking around, I thought of something that *may* be of some help
to you:

http://www.mt4api.net MetaTrader4 .NET api. You can use StatConn/RCom to
interface .NET with R. (http://rcom.univie.ac.at/download.html)

I have a C#/R sample implementation that I can dig up this weekend that
*may* be able to get you started, but that is one way I can think of to
interface MT4/R programmatically for some things. My current environment
is Java, so I am using RServe to interface my java components with R for
intraday stats/etc.

HTH,
C

On 07/25/2010 03:26 AM, yoda55 wrote:
>
> Thanks everyone for the usefull insigths.
> I actually decided to change the way I do things. Research&  Optimization
> stay in R and only the final product get coded in MT4. It makes my life
> easier

_______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: R and Metatrader

jondollar
mt4api looks nice, but a little bit expensive :-(

I've been looking as well at StatConn/Dcom.
It is very good package and free, for interfacing Excel and R, and could be
used as well to interface MT4 with R or Excel, or any COM/DCOM server.
Of course, one needs to write the DLL for MT4, and master the nice Microsoft
COM technology.
As the MT4 DLL are native C/C++, the Statconn wrapper should be in C/C++ as
well.
This is a little bit hard to do because Statconn is not so well documented
for C/C++, so I keep this when I have more time.

Today, I'm interfacing MT4 with Matlab or R, through MySQL database.

I defined one table per security and time frame, for instance EURUSD5, with
DateTime as primary key + OHLCV.
Then I add 8 more empty columns for indicators, ie. Buf0 to Buf7.

These indicators can be calculated in Matlab, R, ..
In MT4, I implemented a custom indicator that reads the Buf0, ... Buf7 from
MySQL and display on the MT4 chart.
Finally, strategies based on this indicator can be tested directly in MT4.
Some trade results can then be stored back by MT4 in MySQL for further
analysis in Matlab or R.

In this way, it's possible to do the long and complex computation outside
MT4, like regression, stat modelling, etc ...
and avoiding to code everything twice for final MT4 code.

Hope that helps ...

PL


2010/7/25 Johnson, Cedrick W. <[hidden email]>

> Just looking around, I thought of something that *may* be of some help to
> you:
>
> http://www.mt4api.net MetaTrader4 .NET api. You can use StatConn/RCom to
> interface .NET with R. (http://rcom.univie.ac.at/download.html)
>
> I have a C#/R sample implementation that I can dig up this weekend that
> *may* be able to get you started, but that is one way I can think of to
> interface MT4/R programmatically for some things. My current environment is
> Java, so I am using RServe to interface my java components with R for
> intraday stats/etc.
>
> HTH,
> C
>
>
> On 07/25/2010 03:26 AM, yoda55 wrote:
>
>>
>> Thanks everyone for the usefull insigths.
>> I actually decided to change the way I do things. Research&  Optimization
>> stay in R and only the final product get coded in MT4. It makes my life
>> easier
>>
>
> _______________________________________________
> [hidden email] 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.
>

        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: R and Metatrader

Bernd Kreuss
In reply to this post by yoda55
yoda55 wrote
Has anyone ever tried to connect R to MetaTrader (MT4 or MT5)?
For the sake of completeness I must point you to this:
http://www.forexfactory.com/showthread.php?t=260422

It does not require to run any kind of server in R or needs any packages installed. It will start Rterm.exe as a background process and communicate with its command line via stdin/stdout. It defines a bunch of functions that let you assign strings, numbers, vectors and matrices to R variables, lets you execute arbitrary R code with a synchronous (blocking) function call and get the results back into MQL4 variables (vectors into arrays)). It has also functions to execute code asynchronously without waiting for it (and then poll for its completion during the following ticks) to make it possible to write MT4 indicators which do not allow long running or blocking tasks.

The DLL itself (full source code is available) is written in Object Pascal (FPC) and the TRConsole class which wraps the Rterm process can also separately be used for your own projects, it does not rely on any windows specific API so it is easily usable with no or only minimal modifications for Linux and Mac applications too.

Bernd
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Quantmod / xts problem " Error in `[.xts`(x, xsubset) : subscript out of bounds"

Immanuel-2
Hello all,

I got some problems while plotting OHLC intraday data
using chartSeries(), ploting of chartSeries(Cl(..) ) works through.

Who knows whats going on?
best regards,
Immanuel

-------------------
> class(intradayData)
[1] "xts" "zoo"
> intradayData[1:5]
                      Open  Close   High    Low Volume  X
2010-05-10 10:00:00 5854.5 5911.0 5925.0 5850.0   2066 NA
2010-05-10 10:10:00 5910.5 5895.0 5911.0 5887.5   1055 NA
2010-05-10 10:20:00 5895.0 5892.0 5901.0 5884.0    913 NA
2010-05-10 10:30:00 5890.0 5903.0 5904.5 5888.5    630 NA
2010-05-10 10:40:00 5903.0 5906.5 5925.0 5901.0    418 NA
> chartSeries(intradayData[1:15])
Error in `[.xts`(x, xsubset) : subscript out of bounds

_______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Quantmod / xts problem " Error in `[.xts`(x, xsubset) : subscript out of bounds"

Jeffrey Ryan
Immanuel,

Not entirely sure what is wrong, but you need to provide reproducible
code for me to do anything more than hazard a guess.

That said, my guess is that something regarding the # of obs you are
plotting or the column ordering is the issue.  I have tried to
replicate both, and don't seem to see an error on my end, so I'll wait
for your code that can be run by me that replicates your error.

Best,
Jeff

On Mon, Oct 25, 2010 at 12:56 PM, Immanuel <[hidden email]> wrote:

> Hello all,
>
> I got some problems while plotting OHLC intraday data
> using chartSeries(), ploting of chartSeries(Cl(..) ) works through.
>
> Who knows whats going on?
> best regards,
> Immanuel
>
> -------------------
>> class(intradayData)
> [1] "xts" "zoo"
>> intradayData[1:5]
>                      Open  Close   High    Low Volume  X
> 2010-05-10 10:00:00 5854.5 5911.0 5925.0 5850.0   2066 NA
> 2010-05-10 10:10:00 5910.5 5895.0 5911.0 5887.5   1055 NA
> 2010-05-10 10:20:00 5895.0 5892.0 5901.0 5884.0    913 NA
> 2010-05-10 10:30:00 5890.0 5903.0 5904.5 5888.5    630 NA
> 2010-05-10 10:40:00 5903.0 5906.5 5925.0 5901.0    418 NA
>> chartSeries(intradayData[1:15])
> Error in `[.xts`(x, xsubset) : subscript out of bounds
>
> _______________________________________________
> [hidden email] 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.
>



--
Jeffrey Ryan
[hidden email]

_______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Quantmod / xts problem " Error in `[.xts`(x, xsubset) : subscript out of bounds"

Immanuel-2
Hey Ryan,

thanks for looking into it.

regards,
Immanuel

------------------
library(quantmod)
library(chron)
library(zoo)


f <- function(x) chron(paste(x[,1]), paste(x[,2], "00", sep = ":"),
            format = c(dates = "d.m.y", times = "h:m:s"))


z <- read.zoo("FDAX_10_min.csv", index = 1:2, header = TRUE, sep =
";",FUN = f)

intradayData <- xts(z, order.by = as.POSIXct(time(z)),unique=FALSE)

chartSeries(intradayData[1:15])
---------------------------------
data file:
------------------------------
Date;Time;Open;Close;High;Low;Volume;
10.05.10;08:00;5854.5;5911;5925;5850;2066;
10.05.10;08:10;5910.5;5895;5911;5887.5;1055;
10.05.10;08:20;5895;5892;5901;5884;913;
10.05.10;08:30;5890;5903;5904.5;5888.5;630;
10.05.10;08:40;5903;5906.5;5925;5901;418;
10.05.10;08:50;5906;5896;5910;5894.5;569;
10.05.10;09:00;5896.5;5892;5901.5;5869.5;786;
10.05.10;09:10;5892.5;5908.5;5909.5;5885;493;
10.05.10;09:20;5908;5915;5916.5;5900;743;
10.05.10;09:30;5914;5936;5937;5904.5;740;
10.05.10;09:40;5937.5;5953.5;5964.5;5933.5;757;
10.05.10;09:50;5953;5942.5;5960;5942;420;
10.05.10;10:00;5942.5;5934.5;5947;5933.5;279;
10.05.10;10:10;5934;5944.5;5949.5;5926.5;366;
10.05.10;10:20;5945;5953.5;5956;5938;261;
10.05.10;10:30;5953;5938.5;5955;5933;96;
10.05.10;10:40;5939;5943;5945.5;5929.5;145;
10.05.10;10:50;5942.5;5972.5;5990;5942.5;248;
10.05.10;11:00;5972.5;5964;5981.5;5963.5;184;
----------------------------------
On 10/25/2010 08:02 PM, Jeff Ryan wrote:

> Immanuel,
>
> Not entirely sure what is wrong, but you need to provide reproducible
> code for me to do anything more than hazard a guess.
>
> That said, my guess is that something regarding the # of obs you are
> plotting or the column ordering is the issue.  I have tried to
> replicate both, and don't seem to see an error on my end, so I'll wait
> for your code that can be run by me that replicates your error.
>
> Best,
> Jeff
>
> On Mon, Oct 25, 2010 at 12:56 PM, Immanuel <[hidden email]> wrote:
>  
>> Hello all,
>>
>> I got some problems while plotting OHLC intraday data
>> using chartSeries(), ploting of chartSeries(Cl(..) ) works through.
>>
>> Who knows whats going on?
>> best regards,
>> Immanuel
>>
>> -------------------
>>    
>>> class(intradayData)
>>>      
>> [1] "xts" "zoo"
>>    
>>> intradayData[1:5]
>>>      
>>                      Open  Close   High    Low Volume  X
>> 2010-05-10 10:00:00 5854.5 5911.0 5925.0 5850.0   2066 NA
>> 2010-05-10 10:10:00 5910.5 5895.0 5911.0 5887.5   1055 NA
>> 2010-05-10 10:20:00 5895.0 5892.0 5901.0 5884.0    913 NA
>> 2010-05-10 10:30:00 5890.0 5903.0 5904.5 5888.5    630 NA
>> 2010-05-10 10:40:00 5903.0 5906.5 5925.0 5901.0    418 NA
>>    
>>> chartSeries(intradayData[1:15])
>>>      
>> Error in `[.xts`(x, xsubset) : subscript out of bounds
>>
>> _______________________________________________
>> [hidden email] 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.
>>
>>    
>
>
>

_______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Quantmod / xts problem " Error in `[.xts`(x, xsubset) : subscript out of bounds"

Daniel Cegiełka
In quantmod you have 'getSymbols.csv' function (as example).

https://r-forge.r-project.org/scm/viewvc.php/pkg/R/getSymbols.R?view=markup&revision=550&root=quantmod

regards,
daniel


2010/10/25 Immanuel <[hidden email]>

> Hey Ryan,
>
> thanks for looking into it.
>
> regards,
> Immanuel
>
> ------------------
> library(quantmod)
> library(chron)
> library(zoo)
>
>
> f <- function(x) chron(paste(x[,1]), paste(x[,2], "00", sep = ":"),
>            format = c(dates = "d.m.y", times = "h:m:s"))
>
>
> z <- read.zoo("FDAX_10_min.csv", index = 1:2, header = TRUE, sep =
> ";",FUN = f)
>
> intradayData <- xts(z, order.by = as.POSIXct(time(z)),unique=FALSE)
>
> chartSeries(intradayData[1:15])
> ---------------------------------
> data file:
> ------------------------------
> Date;Time;Open;Close;High;Low;Volume;
> 10.05.10;08:00;5854.5;5911;5925;5850;2066;
> 10.05.10;08:10;5910.5;5895;5911;5887.5;1055;
> 10.05.10;08:20;5895;5892;5901;5884;913;
> 10.05.10;08:30;5890;5903;5904.5;5888.5;630;
> 10.05.10;08:40;5903;5906.5;5925;5901;418;
> 10.05.10;08:50;5906;5896;5910;5894.5;569;
> 10.05.10;09:00;5896.5;5892;5901.5;5869.5;786;
> 10.05.10;09:10;5892.5;5908.5;5909.5;5885;493;
> 10.05.10;09:20;5908;5915;5916.5;5900;743;
> 10.05.10;09:30;5914;5936;5937;5904.5;740;
> 10.05.10;09:40;5937.5;5953.5;5964.5;5933.5;757;
> 10.05.10;09:50;5953;5942.5;5960;5942;420;
> 10.05.10;10:00;5942.5;5934.5;5947;5933.5;279;
> 10.05.10;10:10;5934;5944.5;5949.5;5926.5;366;
> 10.05.10;10:20;5945;5953.5;5956;5938;261;
> 10.05.10;10:30;5953;5938.5;5955;5933;96;
> 10.05.10;10:40;5939;5943;5945.5;5929.5;145;
> 10.05.10;10:50;5942.5;5972.5;5990;5942.5;248;
> 10.05.10;11:00;5972.5;5964;5981.5;5963.5;184;
> ----------------------------------
> On 10/25/2010 08:02 PM, Jeff Ryan wrote:
> > Immanuel,
> >
> > Not entirely sure what is wrong, but you need to provide reproducible
> > code for me to do anything more than hazard a guess.
> >
> > That said, my guess is that something regarding the # of obs you are
> > plotting or the column ordering is the issue.  I have tried to
> > replicate both, and don't seem to see an error on my end, so I'll wait
> > for your code that can be run by me that replicates your error.
> >
> > Best,
> > Jeff
> >
> > On Mon, Oct 25, 2010 at 12:56 PM, Immanuel <[hidden email]>
> wrote:
> >
> >> Hello all,
> >>
> >> I got some problems while plotting OHLC intraday data
> >> using chartSeries(), ploting of chartSeries(Cl(..) ) works through.
> >>
> >> Who knows whats going on?
> >> best regards,
> >> Immanuel
> >>
> >> -------------------
> >>
> >>> class(intradayData)
> >>>
> >> [1] "xts" "zoo"
> >>
> >>> intradayData[1:5]
> >>>
> >>                      Open  Close   High    Low Volume  X
> >> 2010-05-10 10:00:00 5854.5 5911.0 5925.0 5850.0   2066 NA
> >> 2010-05-10 10:10:00 5910.5 5895.0 5911.0 5887.5   1055 NA
> >> 2010-05-10 10:20:00 5895.0 5892.0 5901.0 5884.0    913 NA
> >> 2010-05-10 10:30:00 5890.0 5903.0 5904.5 5888.5    630 NA
> >> 2010-05-10 10:40:00 5903.0 5906.5 5925.0 5901.0    418 NA
> >>
> >>> chartSeries(intradayData[1:15])
> >>>
> >> Error in `[.xts`(x, xsubset) : subscript out of bounds
> >>
> >> _______________________________________________
> >> [hidden email] 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.
> >>
> >>
> >
> >
> >
>
> _______________________________________________
> [hidden email] 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.
>

        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Quantmod / xts problem " Error in `[.xts`(x, xsubset) : subscript out of bounds"

Jeffrey Ryan
In reply to this post by Immanuel-2
Hi Immanuel,

The extra col/colname is messing something up in chartSeries.  There
is a new version of chartSeries in quantmod (has been for a while)
called chart_Series.  Mostly same behavior, eventually it will be
almost identical to the old version.

The new version is faster, and more extensible.  Also is much nicer to
look at.  And an added bonus is that it also works out of the box on
your example.

Actually both of these do - the former a workaround to get your code
to work with the original chartSeries functionality.

chartSeries(intradayData[1:15,1:5])

chart_Series(intradayData[1:15])

HTH
Jeff


On Mon, Oct 25, 2010 at 1:08 PM, Immanuel <[hidden email]> wrote:

> Hey Ryan,
>
> thanks for looking into it.
>
> regards,
> Immanuel
>
> ------------------
> library(quantmod)
> library(chron)
> library(zoo)
>
>
> f <- function(x) chron(paste(x[,1]), paste(x[,2], "00", sep = ":"),
>            format = c(dates = "d.m.y", times = "h:m:s"))
>
>
> z <- read.zoo("FDAX_10_min.csv", index = 1:2, header = TRUE, sep =
> ";",FUN = f)
>
> intradayData <- xts(z, order.by = as.POSIXct(time(z)),unique=FALSE)
>
> chartSeries(intradayData[1:15])
> ---------------------------------
> data file:
> ------------------------------
> Date;Time;Open;Close;High;Low;Volume;
> 10.05.10;08:00;5854.5;5911;5925;5850;2066;
> 10.05.10;08:10;5910.5;5895;5911;5887.5;1055;
> 10.05.10;08:20;5895;5892;5901;5884;913;
> 10.05.10;08:30;5890;5903;5904.5;5888.5;630;
> 10.05.10;08:40;5903;5906.5;5925;5901;418;
> 10.05.10;08:50;5906;5896;5910;5894.5;569;
> 10.05.10;09:00;5896.5;5892;5901.5;5869.5;786;
> 10.05.10;09:10;5892.5;5908.5;5909.5;5885;493;
> 10.05.10;09:20;5908;5915;5916.5;5900;743;
> 10.05.10;09:30;5914;5936;5937;5904.5;740;
> 10.05.10;09:40;5937.5;5953.5;5964.5;5933.5;757;
> 10.05.10;09:50;5953;5942.5;5960;5942;420;
> 10.05.10;10:00;5942.5;5934.5;5947;5933.5;279;
> 10.05.10;10:10;5934;5944.5;5949.5;5926.5;366;
> 10.05.10;10:20;5945;5953.5;5956;5938;261;
> 10.05.10;10:30;5953;5938.5;5955;5933;96;
> 10.05.10;10:40;5939;5943;5945.5;5929.5;145;
> 10.05.10;10:50;5942.5;5972.5;5990;5942.5;248;
> 10.05.10;11:00;5972.5;5964;5981.5;5963.5;184;
> ----------------------------------
> On 10/25/2010 08:02 PM, Jeff Ryan wrote:
>> Immanuel,
>>
>> Not entirely sure what is wrong, but you need to provide reproducible
>> code for me to do anything more than hazard a guess.
>>
>> That said, my guess is that something regarding the # of obs you are
>> plotting or the column ordering is the issue.  I have tried to
>> replicate both, and don't seem to see an error on my end, so I'll wait
>> for your code that can be run by me that replicates your error.
>>
>> Best,
>> Jeff
>>
>> On Mon, Oct 25, 2010 at 12:56 PM, Immanuel <[hidden email]> wrote:
>>
>>> Hello all,
>>>
>>> I got some problems while plotting OHLC intraday data
>>> using chartSeries(), ploting of chartSeries(Cl(..) ) works through.
>>>
>>> Who knows whats going on?
>>> best regards,
>>> Immanuel
>>>
>>> -------------------
>>>
>>>> class(intradayData)
>>>>
>>> [1] "xts" "zoo"
>>>
>>>> intradayData[1:5]
>>>>
>>>                      Open  Close   High    Low Volume  X
>>> 2010-05-10 10:00:00 5854.5 5911.0 5925.0 5850.0   2066 NA
>>> 2010-05-10 10:10:00 5910.5 5895.0 5911.0 5887.5   1055 NA
>>> 2010-05-10 10:20:00 5895.0 5892.0 5901.0 5884.0    913 NA
>>> 2010-05-10 10:30:00 5890.0 5903.0 5904.5 5888.5    630 NA
>>> 2010-05-10 10:40:00 5903.0 5906.5 5925.0 5901.0    418 NA
>>>
>>>> chartSeries(intradayData[1:15])
>>>>
>>> Error in `[.xts`(x, xsubset) : subscript out of bounds
>>>
>>> _______________________________________________
>>> [hidden email] 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.
>>>
>>>
>>
>>
>>
>
>



--
Jeffrey Ryan
[hidden email]

_______________________________________________
[hidden email] 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.
Loading...