Discussion of article "Deep Neural Networks (Part I). Preparing Data" - page 2

 

Finally translated into Chinese, and worthy of careful study of good articles!

 

Hello!

You didn't describe how you loaded quotes into the env environment ("Since we have loaded vectors of quotes into the env...) and how you created it.

I'm trying to repeat everything from the beginning manually with my quotes, I unloaded them into vectors, but I ran into this environment that you created. I don't understand how to create it and repeat it according to your sample.

Help.

 

The message is gone.

How do you transfer quotes to Rterm? Do you read from a file or from the terminal?

 
Vladimir Perervenko:

The message is gone.

How do you transfer quotes to Rterm? Do you read from a file or from the terminal?


I have more or less figured it out myself. I tried your Part 1 on EURUSD quotes, everything worked.

I do the following:

1. IN MT4 -

for(i = 0; i < lim; i++)

{

tm[i] = Time[i+1];

o[i] = Open[i+1];

hi[i] = High[i+1];

lo[i] = Low[i+1];

clo[i]= Close[i+1];

vol[i]= Volume[i+1];


}

//--------Send data to Rterm--------------------------------------

Rv(R, "Data",tm);

Rv(R, "Open",o);

Rv(R, "High",hi);

Rv(R, "Low",lo);

Rv(R, "Close",clo);

Rv(R, "Volume",vol);

2. IN R -.

price_orig <- cbind(Close = rev(Close), Data = rev(Data), High = rev(High), Low = rev(Low), Open = rev(Open), Volume = rev(Volume) )

price1 <- data.frame(price_orig)

price2 <- as.list(price1)


env <- new.env()

assign("Close", price1$Close, env)

assign("Data", price1$Data, env)

assign("High", price1$High, env)

assign("Low", price1$Low, env)

assign("Open", price1$Open, env)

assign("Volume", price1$Volume, env)

Dig <- 5;

sym <- "EURUSD";

tf <- "M15";


evalq({pr <- pr.OHLCV(Data, Open, High, Low, Close, Volume)}, env)


Could not run charts in MT4, does not pass evalq, %>%, aes, geom_candlestick :

Rx(R, "evalq(pr %>% tail(., 500) %>%

ggplot(aes(x = Data, y = Close)) +

geom_candlestick(aes(open = Open, high = High, low = Low, close = Close)) +

labs(title = "EURJPY Candlestick Chart", y = "Close Price", x = "") +

theme_tq(), env)")");

I tried the old way without the environment variable env, unloaded the data, the command ggplot(,) starts and the window for the chart opens. With parameters, no way.

 
Konstantin Kopylov:

I have more or less figured it out myself. I tried your Part 1 on EURUSD quotes, everything worked.

I do the following:

1. IN MT4 -

for(i = 0; i < lim; i++)

{

tm[i] = Time[i+1];

o[i] = Open[i+1];

hi[i] = High[i+1];

lo[i] = Low[i+1];

clo[i]= Close[i+1];

vol[i]= Volume[i+1];


}

//--------Send data to Rterm--------------------------------------

Rv(R, "Data",tm);

Rv(R, "Open",o);

Rv(R, "High",hi);

Rv(R, "Low",lo);

Rv(R, "Close",clo);

Rv(R, "Volume",vol);

2. IN R -.

price_orig <- cbind(Close = rev(Close), Data = rev(Data), High = rev(High), Low = rev(Low), Open = rev(Open), Volume = rev(Volume) )

price1 <- data.frame(price_orig)

price2 <- as.list(price1)


env <- new.env()

assign("Close", price1$Close, env)

assign("Data", price1$Data, env)

assign("High", price1$High, env)

assign("Low", price1$Low, env)

assign("Open", price1$Open, env)

assign("Volume", price1$Volume, env)

Dig <- 5;

sym <- "EURUSD";

tf <- "M15";


evalq({pr <- pr.OHLCV(Data, Open, High, Low, Close, Volume)}, env)


Could not run charts in MT4, does not pass evalq, %>%, aes, geom_candlestick :

Rx(R, "evalq(pr %>% tail(., 500) %>%

ggplot(aes(x = Data, y = Close)) +

geom_candlestick(aes(open = Open, high = High, low = Low, close = Close)) +

labs(title = "EURJPY Candlestick Chart", y = "Close Price", x = "") +

theme_tq(), env)")");

I tried the old way without the environment variable env, unloaded the data, the command ggplot(,) starts and the window for the chart opens. With parameters, no way.

Good day.

Such transfer from the terminal is unnecessary. You load into the global environment and then transfer to the env environment. After that you will have to clean the global environment. The point of loading and processing data in a separate environment is to avoid name conflict when using several TFs of one symbol or several symbols. All of them are processed by the same scripts and the source data and results have the same names, but each in its own environment. We need to do this:

In Init().

Rx(R, "env <- new.env()");

//Here can be any symbol, for example EURUSD <- new.env(). Then the data will be accessed accordingly EURUSD$price.

In start().

 //--------Send data to Rterm--------------------------------------

      Rv(R,"env$Data",tm);

      Rv(R,"env$Open",o);

      Rv(R,"env$High",hi);

      Rv(R,"env$Low",lo);

      Rv(R,"env$Close",clo);

      Rv(R,"env$Volume",vol);

The data will immediately get into a separate environment env. And further work with them through evalq().

evalq({pr <- pr.OHLCV(Data, Open, High, Low, Close, Volume)}, env)

Try it this way with charts:

Rx(R,"env$pr %>% tail(., 500) %>%

        ggplot(aes(x = env$Data, y = env$Close)) +

        geom_candlestick(aes(open = env$Open, high = env$High, low = env$Low, close = env$Close)) +

        labs(title = "EURJPY Candlestick Chart", y = "Close Price", x = "") + 

        theme_tq()");

I don't output charts this way. Please write me how you check it.

Good luck

 
Vladimir Perervenko:

Good afternoon.

This transfer from the terminal is unnecessary. You load into the global environment and then transfer to the env environment. After that you will have to clean the global environment. The point of loading and processing data in a separate environment is to avoid name conflict when using several TFs of one symbol or several symbols. All of them are processed by the same scripts and the source data and results have the same names, but each in its own environment. We need to do this:

In Init().

Rx(R, "env <- new.env()");

//Here can be any symbol, for example EURUSD <- new.env(). Then the data will be accessed accordingly EURUSD$price.

In start().

The data will immediately get into a separate environment env. And further work with them through evalq().

Try it this way with charts:

I don't output charts this way. Please write me how you check it.

Good luck


Everything worked with the upload. Thank you!

But with the graph, it doesn't work. It gives an error. Although the libraries are loaded.

Rx(R, "library(magrittr)");

Rx(R, "library(dplyr)");

Rx(R, "library(xts)");

Rx(R, "library(anytime)");

Rx(R, "library(quantmod)");

Rx(R, "library(TTR)");

Rx(R, "library(ggplot2)");


Checked the same thing in RStudio, it doesn't find %>%.( Error in env$pr %>% tail(., 500) %>% ggplot(aes(x = env$Data, y = env$Close)) :

 could not find function "%>%")
 
Konstantin Kopylov:

Everything worked out with the upload. Thank you!

But with the graph, it's not working. It gives an error. Although the libraries are loaded.

Rx(R, "library(magrittr)");

Rx(R, "library(dplyr)");

Rx(R, "library(xts)");

Rx(R, "library(anytime)");

Rx(R, "library(quantmod)");

Rx(R, "library(TTR)");

Rx(R, "library(ggplot2)");


Checked the same thing in RStudio, it doesn't find %>%.( Error in env$pr %>% tail(., 500) %>% ggplot(aes(x = env$Data, y = env$Close)) :

In this script, %>% is out of place. Try

Rx(R,"env$pr %>% tail(., 500) -> tpr;

        ggplot(aes(x = tpr$Data, y = tpr$Close)) +

        geom_candlestick(aes(open = tpr$Open, high = tpr$High, low = tpr$Low, close = tpr$Close)) +

        labs(title = "EURJPY Candlestick Chart", y = "Close Price", x = "") + 

        theme_tq()");

It is better to write all this in R instead of in the terminal. I'm not sure if this combination will work. I haven't written like that in a long time, so no opinion.

Good luck

 
Vladimir Perervenko:

In this script, %>% is out of place. Try it


It doesn't work, the error both through MT4 and in RStudio:

> env$pr %>% tail(., 500) -> tpr> 
> ggplot(aes(x = tpr$Data, y = tpr$Close)) + + +    
 + geom_candlestick(aes(open = tpr$Open, high = tpr$High, low = tpr$Low, close = tpr$Close))) + ++     
 + labs(title = "EURJPY Candlestick Chart", y = "Close Price", x = "") + ++     
 + theme_tq()Error:ggplot2 doesn't know how to deal with data of class uneval

So inserted into MQL Rx(R, "env$pr %>% tail(., 500) -> tpr"); Rx(R, "ggplot(aes(x = tpr$Data, y = tpr$Close)) + geom_candlestick(aes(open = tpr$Open, high = tpr$High, low = tpr$Low, close = tpr$Close)) + labs(title = 'EURUSD Candlestick Chart', y = 'Close Price', x = '') + theme_tq())");

 
Konstantin Kopylov:

It doesn't work, error both through MT4 and in RStudio:

Something has been improved in ggplot2. I'll check it now.
 

In ggplot2(v2.2.1) the definition of geom_candlestick (MRO 3.4.1) disappeared.

I have already torn down MRO 3.4.0 in which I did all the calculations so I will find a solution tomorrow and write.

What version of R do you have ?