Discussion of article "Third Generation Neural Networks: Deep Networks" - page 6

 

Another quick test, this time with a 6000 bars training set from September 2014 until Febrary 2015. Out of sample test starts in March:

  

Again we have a profitable phase of about 5 weeks until the model deteriorates.

I believe the splitting into test and training data is unnecessary: we can use all data for training. The accuracy and confusion matrix are misleading because in most cases the ZZ sign is identical to the sign of the previous bar, wrongly suggesting a high accuracy. For the profit, only the sign changes matter. 

 
jcl365:

I habe now trained a new model with prediction of the next bar, and it seems that it indeed works. The accuracy is still in the 74% range. This is the equity curve now:

:

It behaves just as I would expect: the system is profitable immediately after training, and then slowly deteriorates as the market changes.  

So the next step is a WFO test with regular re-training of the model. For this the training must be integrated in the strategy script.

This is the corrected function for calculating the Sig of the next bar:

 The "Compute" function that is executed every 30 mins by the strategy script:

 The strategy script, the "EA":

jcl365:

I habe now trained a new model with prediction of the next bar, and it seems that it indeed works. The accuracy is still in the 74% range. This is the equity curve now:

:

It behaves just as I would expect: the system is profitable immediately after training, and then slowly deteriorates as the market changes.  

So the next step is a WFO test with regular re-training of the model. For this the training must be integrated in the strategy script.

This is the corrected function for calculating the Sig of the next bar:

 The "Compute" function that is executed every 30 mins by the strategy script:

 The strategy script, the "EA":

Hi

You moved the series ZZ one bar in the future.

for(i in 1:length(ZZ)-1) { ZZ[i] = ZZ[i+1] }

You moved the series dz one bar in the future.

 dz <- c(diff(ZZ), NA)

So you moved the target variable in the two bars into the future.

This is equivalent to

dz <- Hmisc::Lag(diff(ZZ), shift=-2)

This option can also be used.


 


Again we have a profitable phase of about 5 weeks until the model deteriorates.

This is normal. The model can and should be periodically re-learn.

I believe the splitting into test and training data is unnecessary: we can use all data for training.

Can. It is important to remember a few important points:
1. training and test sets should not be crossed.
2. The training set should be mixed

3. If the ratio of classes of balance - to make the adjustment.

I am glad that there were colleagues using R.

Best Regards

Vladimir

 

You're right with the double shifting: What the system in fact predicts is a ZZ difference that is based on the mid-price of the next bar. The ZZ is calculated from the mid-prices, but at calculation time we have the close price, which its normally about halfway between the last and the next mid-price. So the additional shifting predicts about 1.5 bars into the future, and in fact I got far worse results without the additional shift. 

I have now a Zorro script that re-trains every 4 weeks, and tests the 4 weeks following on the training. The deepnet is pretty fast, the script needs only about 10 minutes for a run covering about 60 training/test cycles. This is the result:

  

This does not look as good as the first impressions. There is clearly potential for improvement, so the next steps would be experimenting with different network setups, time periods, and different indicators.

 
We need to pick up not only the indicators but also their parameters. Gene algorithm help you.

What is Zorro? give the links?


 
Vladimir Perervenko:
We need to pick up not only the indicators but also their parameters. Gene algorithm help you.

What is Zorro? give the links?


Yes, there is a book by Yu / Wang / Lai that describes a genetic algorithm for preselecting indicators for NN Forex training. - I use Zorro because scripts are simpler and backtesting is better, but I guess MT4 would do also with some effort. I can't give a link as this is a MT4 website, but you can google for Zorro trading automaton. The R dll by Bernd Kreuss works with Zorro also.
 

I have downloaded and installed everything and put all files into the Folders. All packages are installed. Folders are set to my destinations.

When i put the expert on the EURUSD m30 Chart everything is fine even in DebugView, but as soon as i put the indicator on the Chart i get an Error:

ExecutedCode: in  >>>  as.Logical(res <-GetRes()) [1]

Error in if (z) { :

The result of the function GetRes in "i_SAE_fun.r" is always NA and so he can not convert this to bool and stops working.

Anyone can point me to the right direction? what am i missing?

Best regards,

APoLLo

 
APoLLo_MQL:

I have downloaded and installed everything and put all files into the Folders. All packages are installed. Folders are set to my destinations.

When i put the expert on the EURUSD m30 Chart everything is fine even in DebugView, but as soon as i put the indicator on the Chart i get an Error:

ExecutedCode: in  >>>  as.Logical(res <-GetRes()) [1]

Error in if (z) { :

The result of the function GetRes in "i_SAE_fun.r" is always NA and so he can not convert this to bool and stops working.

Anyone can point me to the right direction? what am i missing?

Best regards,

APoLLo

Hi APoLLo.

Which version R You have ?
This is a fairly long article and after the update packages in R some functions stop working.
Better use Revolution R Open (RRO 8.01)
To check, run a script in Rstudio.

If you have time, I also check where the error is.

Best regards/

Vladimir

Revolution R Open
  • www.revolutionanalytics.com
Revolution R Open is our enhanced distribution of the world's most widely used data analysis software. Based on open source R, Revolution R Open is built, tested and distributed by Revolution Analytics and delivers: The latest R language engine from the R Foundation for Statistical Computing High-performance R language engine (multi-threaded...
 
Vladimir Perervenko:

Hi APoLLo.

Which version R You have ?
This is a fairly long article and after the update packages in R some functions stop working.
Better use Revolution R Open (RRO 8.01)
To check, run a script in Rstudio.

If you have time, I also check where the error is.

Best regards/

Vladimir

I am using the latest Version of R 3.2.0 64bit together with the latest MT4 build. All packages for R are downloaded yesterday so they should be latest version too.

If i start the EA on EURUSD M30 i can even connect to it with the RGUI and check for "SAE" and "prepr" and get a lot of numbers back.

For me it Looks like the GetRes function in R is checking if a Connection is open by retrieving the flag1 value which is not available on the Server (EA).

Maybe its the cause because "Acc" or "K" or "Kmax" got never calculated correct.


I have time so if you have the chance to take a look i would be very happy.

Later i will try Revolution R 8.01 to check if this works better.

Thx for you help :)

 
Vladimir Perervenko:

A HUGE THANK YOU to the author for the article. I started to familiarise myself with the application of neural networks to the market with your article. I was not familiar with neural networks before and had never used the R language. But now I have installed it and am learning it. It seems complicated, but interesting!

And yes, please tell me, I can't understand how the SAE.model file works as a library for an Expert Advisor or as what? That is, can we save the neural network structure from R and then use it as a regular library in an Expert Advisor, or what? It's all very confusing and complicated (for me).