Build Neural Network Indicator in MT4 using Neuroshell

Hi Krzys,

Thanks for your given link, by the way here is the complete ebook

http://www1.cs.columbia.edu/~gms2155/projectspring2009/

Here are the complete collection about tradefx available there
[ ] Project1a.pdf 09-Sep-2009 23:03 1.8M
[ ] Project1b.pdf 09-Sep-2009 23:04 3.0M
[ ] Project2a.pdf 09-Sep-2009 23:06 6.4M
[ ] Project2b.pdf 09-Sep-2009 23:06 1.2M
[ ] Project3a.pdf 09-Sep-2009 23:07 941K
[ ] Project3b.pdf 09-Sep-2009 23:07 75K
[ ] Project4a.pdf 09-Sep-2009 23:07 808K
[ ] Project4b.pdf 09-Sep-2009 23:07 421K
[ ] Project5a.pdf 09-Sep-2009 23:07 520K
[ ] Project5b.pdf 09-Sep-2009 23:08 2.7M
[ ] Project6b.pdf 09-Sep-2009 23:09 3.8M

The correct link for tradefx is http://www.columbia.edu/~xv2103/finance/TradeFX/TradeFX.zip

Additional link for MT4 to Matlab for producing csv file is available here:
http://articles.mql4.com/440

I trace the required LibSVM has no more available. Any one can advice?

Arryex
 
Last edited:
Hi Krzys,

Thanks for your given link, by the way here is the complete ebook

http://www1.cs.columbia.edu/~gms2155/projectspring2009/

Here are the complete collection about tradefx available there
[ ] Project1a.pdf 09-Sep-2009 23:03 1.8M
[ ] Project1b.pdf 09-Sep-2009 23:04 3.0M
[ ] Project2a.pdf 09-Sep-2009 23:06 6.4M
[ ] Project2b.pdf 09-Sep-2009 23:06 1.2M
[ ] Project3a.pdf 09-Sep-2009 23:07 941K
[ ] Project3b.pdf 09-Sep-2009 23:07 75K
[ ] Project4a.pdf 09-Sep-2009 23:07 808K
[ ] Project4b.pdf 09-Sep-2009 23:07 421K
[ ] Project5a.pdf 09-Sep-2009 23:07 520K
[ ] Project5b.pdf 09-Sep-2009 23:08 2.7M
[ ] Project6b.pdf 09-Sep-2009 23:09 3.8M

The correct link for tradefx is http://www.columbia.edu/~xv2103/finance/TradeFX/TradeFX.zip

Additional link for MT4 to Matlab for producing csv file is available here:
http://articles.mql4.com/440

I trace the required LibSVM has no more available. Any one can advice?

Arryex

Arryex and Krzys
Is this the matlab file you want?
 

Attachments

  • libsvm-matMatLab-3.0-1.zip
    84.1 KB · Views: 257
I made some investigations of TradeFX system over weekend. Installation is straight forward, just necessary to create directory
C:\Program Files\MetaTrader 4 at FOREX.com and copy MT4 files there.

Official reports of this system is

http://www.columbia.edu/~xv2103/finance/TradeFX/Report.htm

and ppt and doc files in directory

http://www.columbia.edu/~xv2103/finance/

Only one thing which is not working is evalStrategy script. To get it working is necessary to merge it with run_svm script.

For people interested in SVM theory here is very good video course

http://videolectures.net/epsrcws08_campbell_isvm/

Overall it's very interesting and advanced system for free to play :clap:

Krzysztof
 
Fralo,

Thanks, I will verify it.

Arryex
Arryex.. The library I sent is not official MatLab. So to use it you must compile as matlab file. But it still will not be useful to try TradeFX system, because program functions are not the same names and I/O may be different. :eek:

I discovered, as you probably know, that there are many LibSVM packages for MatLab available as freeware. I have found none that contain the correct versions of the train and classify code.

However, TradeFx uses only svmtrain.m and svmclassify.m from the library. Both of those are in the biolearning toolbox that is usually packaged with MatLab, so you probably don't need the official LibSVM toolbox.
fralo
 
some conclusions

I believe this thread needs a kind of summary and intermediate conclusions as a lot of work was done by me, fralo and arryex specjally at 1st part of the year.

Just to remind you what was done:

Arry proposed using Ward programs (NS, NS2, Predictor, Chaos Hunter) to generate trained NN and use them as as indicator in MT4.

Me and fralo we trying to train different back propagation nets using MBP program. Our goal was to minimize RMSE, we were trying different network architectures and different input combinations. Additionally I was using Neuroshell which is using genetic optimizer and comparing its results with results obtained by MBP.

So far my conclusion (at least from my part) was that it was not possible to minimize RMS to the level which will give profitable strategy at least for EURUSD. Different network architectures, changing number of inputs were no changing RMS much,
final RMS was very similar for all configurations, only training time was different.

Training were done in my case for 60k IS samples and 5k OOS sample to avoid impact of randomness.

Similar tests were conducted with Neuroshell and results were similar. Only difference was that the training with NS was very fast comparing to MBP which was using CUDA acceleration, OOS generalization was poorer than in case of using MBP trained nets so it suggests that using Genetic Algorithm for optimizing inputs introduces huge Data Mining Bias error. This method was introduced by Ward like 10 years ago most likely to be compliant with computing power of this time PCs....

What can be done:

Real multimarket test with a lot of low correlated inputs (like Bond prices, oil, gold, S&P) was not done. I collected all data for such DB but haven't don this test. Its clear that such DB must have also another data inputs like e.g. time to show the monthly cycle, the dates of major news reports etc.

Recently Noel has released two new type of kernels for GPUMLIB directory Radial Basis Function Networks and Non-Negative Matrix Factorization so this can also be checked to see if RMS is lower using this methods.

Is somebody also have some conclusions don't hesitate to post it.

Krzysztof
 
Re: some conclusions

Is somebody also have some conclusions don't hesitate to post it.

Krzysztof
I agree with this post, but want to add some other results. I wanted to compare various data bases using both NS2 and MBP, so I concentrated on predicting EUH1 high and low. I used 15000 training samples, and 5000 OOS samples. As a reference, I used the previous bar high to predict high. For EUH1 this will result in an rmse of ~16.15 pips. I found that I could reduce this to 12.15 pips using features derived from EUH1 OHLC. When I used features derived from EU,EG,GJ,GU, UJ , I could achieve an rmse of 10.35 pips. It is quite possible that I can reduce this further by using features from gold, oil, and stock indices; however, many of the features that I have used depend on first and second differences. FX data is 24/5. Most futures data are not. This leaves holes that translate into problems with first and second differences if you use lags. I am still struggling with how to treat these holes.

I also tried to devise a strategy to trade using these predictions. If you know what the next bar high and low will be, you can devise a very powerful, simple strategy. If you have 'fuzzy' knowledge, then the strategy needs to be more complex. I can use the 12.15 rmse prediction to get + return, but the profit factor and expected payoff are so low that the result may easily be random. I will post the report if someone is interested.

I am in the process of trying a strategy that uses the multi-pair data (10.15 rmse) and performing a truncated set of experiments predicting EUH4, but I doubt that the results will improve drastically.

One other observation. For these predictions, I found that the linear regression net (no hidden layer) from MBP almost always does as well as multi-hidden layer nets. Similarly the GMDH net from NS2 does as well or better than Ward nets. However, in some cases (certain types of data bases) the EJ recurrent net in NS2 is slightly better than others. Also, for my problem, training for more than a few minutes had negligible effect on the rmse.

If someone wants more details, please tell me what you would like to know.
 
Re: some conclusions

I believe this thread needs a kind of summary and intermediate conclusions as a lot of work was done by me, fralo and arryex specjally at 1st part of the year.

Just to remind you what was done:

Arry proposed using Ward programs (NS, NS2, Predictor, Chaos Hunter) to generate trained NN and use them as as indicator in MT4.

Me and fralo we trying to train different back propagation nets using MBP program. Our goal was to minimize RMSE, we were trying different network architectures and different input combinations. Additionally I was using Neuroshell which is using genetic optimizer and comparing its results with results obtained by MBP.

So far my conclusion (at least from my part) was that it was not possible to minimize RMS to the level which will give profitable strategy at least for EURUSD. Different network architectures, changing number of inputs were no changing RMS much,
final RMS was very similar for all configurations, only training time was different.

Training were done in my case for 60k IS samples and 5k OOS sample to avoid impact of randomness.

Similar tests were conducted with Neuroshell and results were similar. Only difference was that the training with NS was very fast comparing to MBP which was using CUDA acceleration, OOS generalization was poorer than in case of using MBP trained nets so it suggests that using Genetic Algorithm for optimizing inputs introduces huge Data Mining Bias error. This method was introduced by Ward like 10 years ago most likely to be compliant with computing power of this time PCs....

What can be done:

Real multimarket test with a lot of low correlated inputs (like Bond prices, oil, gold, S&P) was not done. I collected all data for such DB but haven't don this test. Its clear that such DB must have also another data inputs like e.g. time to show the monthly cycle, the dates of major news reports etc.

Recently Noel has released two new type of kernels for GPUMLIB directory Radial Basis Function Networks and Non-Negative Matrix Factorization so this can also be checked to see if RMS is lower using this methods.

Is somebody also have some conclusions don't hesitate to post it.

Krzysztof

Krzysztof,

There is an interesting interwiev : http://championship.mql5.com/2010/en/news/16
 

Attachments

  • error_profit1.png
    error_profit1.png
    21 KB · Views: 544
  • error_profit2.png
    error_profit2.png
    15.6 KB · Views: 487
Re: some conclusions

Krzysztof,

There is an interesting interwiev : http://championship.mql5.com/2010/en/news/16

Hi,

Thanks for the link, i just read this. What i can say. The statements like

Further, as the training time increases, the error will also gradually decrease, and profit on OOS can produce several more maximums, but they are usually less than the very first one. Although I encountered a situation where the second and even the third maximums were higher than the first one. But it is believed that the first maximum is better than the rest in terms of profitability and efficiency. In fact, our task is to catch this first maximum. And it depends on skills and experience of the trader - I don't know any other, more accurate criteria. Although, of course, we may and should be guided by the percentage of profitability, error, drawdown, Sharpe ratio, and many other parameters. But ultimately, it depends solely on the trader what criteria to use. And it depends on how he understands his TS and knows how it behaves.

or

Then a natural question arises: What part of the market should be given to a network for training? Here is the answer: the part where the network successfully recognizes patterns and market areas necessary for a TS and the trader. This depends on a trader's skills - the way he sees the market and how well he can choose the right part for training. In my experience this is from 500 to 2000 bars depending on the timeframe and market state.

or

The essence of the market doesn't change - only its character is changing, which an experienced trader must keep track of, timely adjusting his TS to the new, changed market conditions.

sounds bit a vodoo for me. Seems he refers always to term 'experienced trader'
and for me experienced trader = experienced roullete player which was just lucky for a while :D
 
Re: some conclusions

When I used features derived from EU,EG,GJ,GU, UJ , I could achieve an rmse of 10.35 pips. It is quite possible that I can reduce this further by using features from gold, oil, and stock indices;

Fralo, what exactly features did you used, what is "EU,EG,GJ,GU, UJ" - EuroUsd ( already used ), EuroGpb, GpbJpy, etc ?
I think, for EuroUsd it makes sense to use corresponding to Euro and Usd instruments - EuroGpb, GpbUsd and UsdJpy from your list.
I've been watching your thread for a couple of weeks, i think Neural Networks are not so good for price predictions. For a few years, a lot of articles and researches showing SVM ( Support Vector Machines ) as better alternative for market predictions. SVM has no local-minimum traps and overfitting.
Right now i'm checking strategy for SVM+WAVELETS combination, based on Electricity market research. It can't predict minimum/maximum of feature price bar very well, but can do it well to predict future price movements.
I'm using MATLAB + MetaTrader, one for calculations and another for input data ( indicators, EU, EG, GU, etc. ) provider.
As soon as i'll complete tests, i'll publish results here.
 
DWT gives 1 pip RMSE !!!

Wow, in this MSc thesis author was doing exactly the same what we were doing and
data preprocessed with Discrete Wavelet Transform gave him 1.7 pip RMSE for
GBPUSD !!!!

Easy to check just preprocess with Matlab and train with MBP

http://taco.poly.edu/WaveletSoftware/

Than he should be richer than Bil Gates by now :D

Krzysztof
 

Attachments

  • zzzz.JPG
    zzzz.JPG
    101 KB · Views: 508
  • Chong_Jul2009.pdf
    1.5 MB · Views: 2,393
Re: some conclusions

Fralo, what exactly features did you used, what is "EU,EG,GJ,GU, UJ" - EuroUsd ( already used ), EuroGpb, GpbJpy, etc ?
I think, for EuroUsd it makes sense to use corresponding to Euro and Usd instruments - EuroGpb, GpbUsd and UsdJpy from your list.
I've been watching your thread for a couple of weeks, i think Neural Networks are not so good for price predictions. For a few years, a lot of articles and researches showing SVM ( Support Vector Machines ) as better alternative for market predictions. SVM has no local-minimum traps and overfitting.
Right now i'm checking strategy for SVM+WAVELETS combination, based on Electricity market research. It can't predict minimum/maximum of feature price bar very well, but can do it well to predict future price movements.
I'm using MATLAB + MetaTrader, one for calculations and another for input data ( indicators, EU, EG, GU, etc. ) provider.
As soon as i'll complete tests, i'll publish results here.
Sorry to take so long to answer. Yes e.g. EU is EURUSD, etc.
I used 3 T3 filters on a pair: High, Low, and Close
Then found the difference between H,L,C and the filters.
Call these dH,dL,dC
Call the slope and momentum of the filter ST3 and MT3
For the data base that resulted in 10 pip rmse, I used
From EU: dH,dL,dC and lag1 and lag2 of these, for 9 elements of the input vector
and added ST3 and MT3 for high or low depending on the target.
Then I added dH,dL, and ST3,MT3 for EG,GJ,GU,and UJ for 16 more elements.
Total 27 elements in the input vector.

I used dH as one target and dL as the other.

All of the elements are at least first differences, so they are at least quasi-stationary, which I think is necessary for good generalization.

However, it seems like a pretty complicated way to get a prediction that is still pretty poor.

Regarding SVM. Since SVM transforms data to a much higher dimensional space, it suffers from the curve-fitting problem as much as other models. (The higher the dimensionality of a model, the more adjustable parameters, so the easier to curve-fit). Finding an SVM model on one block of data may not generalize any better or even as well as properly trained NN's.
 
Hi All,

So long not to check ..seems so far so many development on going here..

Tovim, if you have already an neural network engine (program, dll etc) which is used to to train the NN to produce the predicted output, then you can call it to run whenever the new data (Close or other) completed. Since it will become an online training, then it will depend on some factors: input, output, complexity and method of NN calculation and your computer speed.

Most of case if your calculation used to train is longer than the used time frame ..the prediction will be useless since the output is delayed, example if you PC can train the NN based on new data within 3 minutes, you should not use it to predict 1 minutes data. Just an opinion...
 
I haven't read all the pages from this thread, but I read more than enough and I can see you guys have considerable interest in AI algorithms for trading. Unfortunately I also think you're taking the wrong approach. The company I represent has successfully built an MT4 indicator which can predict the MACD with good accuracy and is now in progress of building other indicators on the same principle, so I'd like to share a few thoughts:

You're trying too many strategies! There's a reason neural networks have been successful. They work great in recognizing patterns and that's what Forex is all about! If you haven't found a solution, then you haven't searched hard enough, because the solution exists. There's also a reason why SVM's and other algorithms are or should be successful. They work too, in classification or other stuff specific to each algorithm. They all work and they should all work in Forex. Pick a strategy and stick to it no matter what. Learn it by heart, learn how to adapt it and learn how changing it's parameters changes it's behavior. Don't try too many different things or you won't be successful in neither.

Normalize the data you're using. If you don't know what this means, google it. It's one of the most important things you can do, no matter which algorithm you pick.

Adding more layers to a neural network doesn't make it better. 3 layers is more than enough, if you choose the correct number of neurons.

Performing more iterations doesn't make the solution better. It will probably make it worse. I saw references here to >1.000.000 iterations. Are you kidding me? This is way too much. You're just over-training your algorithm and it's not going to perform well in practice.
 
Hi Proteus,

Congratulation, for your development of indicator.

Since beginning, the initial idea of this thread is to share and develop the knowledge how to build indicator/EA in MT4 using Neural Network whatever the software used.

So far you mentioned on your web:
- inputs NN are some indicator RSI, price, etc
- output NN is 5 bar MACD (20, 200,20)
- You used out of sample data to define the accuracy of prediction (bar #1 - MACD main: 90%, MACD signal: 95%; bar #2 - MACD main: 88%, MACD signal: 92% etc), those are made based on 150 random test over 20K training data). How do you make such percentage? currently we use term of MSE, RMSE, same sign, etc to measure the accuracy. I do not think we use similar value as percentage, for example put 100% correct if all predicted values are same as actual.If you have 90% accuracy, means over the 20000 values of MACD, your prediction has 90% same value..I do not know the pip you are using 5 digit or 4 digit decimal?

I don't know your way to display the indicator, either firing the net by putting trained NN in mq4 code or calling dll. For saving your code, I guest dll calling is preferred.

Do you have develop also the EA based on your indicator? only by knowing the trading statistic we can conclude that indicator is useful or not.

Hope you can share your idea as well...
Arryex
 
Top