Build Neural Network Indicator in MT4 using Neuroshell

Hi Ziko,

It is possible to display the result of prediction (output) as an indicator. You already explain your first step on your NN design, i.e. define inputs and outputs.

Further more detail questions:
- What is pair you are using (EURUSD or GBPUSD or else) ?
- which time frame (15m, 60m, or else)?
- How many bars of your data used for training and which one used to train, test or produce? which one (is it selected randomly or in sequence)?

Can you submit your training data (in csv) and pattern file (.pat), since the trained net usually different result for different pair. I may help you to verify correctness you pattern file with your prediction objective.
Those above question should be part of your neural network design.

Thanks
 
in the file you'll find two network,,withe the same input and output,,the only diffrence is in the structure of the network
 
Hi Ziko,

In the csv file that you have, is it RSI Close (last column) is the future bar of RSI or Current bar of RSI.

Your data collector script (previous RSI to FIle.mq4) has current bar of RSI, if you want to put the next bar as predicted, your data script shall be modified, such as:
iRSI(SymbolName,PeriodMinutes,14,PRICE_OPEN,i-1)

This to get next bar RSI.
I will start to train after your confirmation.
 
in the csv file the last column is RSI Close of the curent bar and it's the output of my network,like that when the 1h bar open we have rsi open and the predicted value of the rsi close for the current bar ,like that i can know if i sould buy or sell in the opening of tha bar
 
yes it's true fralo the open of the predicted bar=the close of the current bar it's the same,,for the moment i just try to predicted one bar in the future but next it will be more,,,and i changed from rsi open price to the close price,, i use input like this:
open(1)close(1)high(1)low(1)volume(1)rsi open price(1)rsi close price(1)open(0)rsi open price(0)
and one output:
rsi close price of the current bar
that make me 9 input and 1 output
do you think that you can make me an indicator using this inputs to show the value of the output?
i tried many times but i think that i can't made it,the def file is in this link
http://www.mediafire.com/?8bdak7vjcemt90i
i don't know why the def files are not accepted in the attachement
thank you.
Here is a simple indicator that should load your inarray, fire your net and place the output in a buffer for display. I have not debugged the DLL call, since I have no time for a few days, but if you place the def file in the folder that you originally specified, and have the NS32.dll in the correct folder, then it should work. In any case, look at the code. It is commented so that you can see what needs to be done. It should work as is. Keep me posted on your results. Good Luck.:)

To attach a def file here, you must first zip it, or change the extension to one of the acceptable extensions. This forum will not accept *.def files for security reasons.
 

Attachments

  • RSI-NN.mq4
    3.5 KB · Views: 430
Hi ZIko,

I verified that there is no problem with your def file, I succeed to call def file from excel to shown the predicted values.

Unfortunately, I could not showing the indicator values in MT4, return error ret =-65495.

see attached pictures, I am not sure the cause of problem in MT4, probably:
- We do not make any limitation on the code if the output array is more than 100 or less than -100
 

Attachments

  • call dll in excel.PNG
    call dll in excel.PNG
    66.2 KB · Views: 1,152
  • error in mt4.PNG
    error in mt4.PNG
    49.2 KB · Views: 517
Hi ZIko,

I verified that there is no problem with your def file, I succeed to call def file from excel to shown the predicted values.

Unfortunately, I could not showing the indicator values in MT4, return error ret =-65495.

see attached pictures, I am not sure the cause of problem in MT4, probably:
- We do not make any limitation on the code if the output array is more than 100 or less than -100
Hello Arryex and Ziko..
I have no experience using NS32.dll. MT4 has many problems calling dlls, and it may be that one of these is causing your difficulties. However, I have had much success calling DLLs generated using Visual C.

I have had success using NS2 to generate C source code for a network, and then compiling that as a DLL. You have better control of the process that way, and can debug the dll using visual C which has a reasonable debugger.(You must write a C source calling program first though.)

Have you looked at the code I posted? I did not change the way that you indexed the computation, and it may be that there is a problem there. In the past I have had problems with MT4 using 'while(i<0)' clause. For some reason MT4 occasionally wants just 'for(i=limit...)' clauses. Very peculiar behavior. :)
 
Hi Fralo/Ziko,

Based on rsiclosepre.pat file, the column is arranged as follow:
Date,Open1,Close1,High1,Low1,Open0,Volume1,RSICLose1,RSICLose0,RSIOpen0,RSIOpen1
Ziko please confirm.

I compiled your code (RSI-NN.mq4), but still give same result as shown here.

Which version of visual studio used, do you have sample of converted c code from NS2 prior compile into dll. I assume you made some changes on the original code generated by NS2 prior compilation, please correct me if wrong.

Thanks
 

Attachments

  • error in mt4 fralo.PNG
    error in mt4 fralo.PNG
    52.2 KB · Views: 448
Hi Fralo/Ziko,

Based on rsiclosepre.pat file, the column is arranged as follow:
Date,Open1,Close1,High1,Low1,Open0,Volume1,RSICLose1,RSICLose0,RSIOpen0,RSIOpen1
Ziko please confirm.

I compiled your code (RSI-NN.mq4), but still give same result as shown here.

Which version of visual studio used, do you have sample of converted c code from NS2 prior compile into dll. I assume you made some changes on the original code generated by NS2 prior compilation, please correct me if wrong.

Thanks
That is different than the inputs used in the indi I posted. When I have time I will try to make a mod and debug.

Meanwhile here is an indicator that uses a dll compiled from NS2 source. ALL files needed are included. Indicator is commented and explanation of mods needed for VC++ compilation. Somewhere I have an EA that uses this indicator. It did not work well, so it is in the attic of my mind, and not well remembered.:)
 

Attachments

  • PT3.zip
    8.5 KB · Views: 284
Hi fralo/arryex,
fralo thank you for the indicator,he works well,,the probleme is in the inputs,,when i use the def file that i give you he show me the same error as arryex,,but i changed the input like that:
rsi close(1),rsi close(2),rsi close(3),rsi close(4),input with values comming from the same indicator and it's work,,the indicator show the output
now i'm gonna to try to train networks to see what kind of networks give the best results
Thank you.
 

Attachments

  • chart.gif
    chart.gif
    12.1 KB · Views: 535
Hi fralo/arryex,
fralo thank you for the indicator,he works well,,the probleme is in the inputs,,when i use the def file that i give you he show me the same error as arryex,,but i changed the input like that:
rsi close(1),rsi close(2),rsi close(3),rsi close(4),input with values comming from the same indicator and it's work,,the indicator show the output
now i'm gonna to try to train networks to see what kind of networks give the best results
Thank you.
Welcome:D
Now I don't have to debug it.:clap:
 
Hi Ziko/Fralo,

I think the source of problem is the inputs for the net especially the OHLCV, after I remove them and replace with RSI data only, retrain with other inputs, it works.

The next task are to improve the net quality and create an EA based on this predicted RSI, any idea?

thanks
 

Attachments

  • aaNeuroRSI.PNG
    aaNeuroRSI.PNG
    86.3 KB · Views: 605
Hi Ziko/Fralo,

I think the source of problem is the inputs for the net especially the OHLCV, after I remove them and replace with RSI data only, retrain with other inputs, it works.

The next task are to improve the net quality and create an EA based on this predicted RSI, any idea?

thanks
Yes, I mistook the inputs from one of Ziko's posts. I thought that the OHLVC were included. You were right, if the net is trained on RSI then introducing OHLVC could easily overload it and drive the output to an extreme.

EA performance will depend on how the result is used. Suppose you could predict the RSI in one, two, three bars. How would you use it? Is there an EA that uses the RSI that could be improved by using the prediction? How accurate does the prediction have to be? Is it that good?

Writing an EA from scratch is not really too hard, but you must first know how you will use the indicator. What is your idea? How well does your net work? If you plan to use a threshold on the RSI, then the rmse of the prediction will be important.

To make the EA work, you also need some kind of money management and exit strategy. All these should be described just as you would specify a new engineering design. Then the EA will follow easily.:rolleyes:
 
Hi Fralo,

Based on my few tests using NSDT, Trading strategy based on RSI was not giving the consistent result, I tried using conventional RSI cross over a threshold such as 30 and 70. Event using the predicted RSI (5 or 10 bar) still not giving a good result.

I consider to build an EA if using NSDT showing a positive result.

Any one have tried other methods?
 
Hi,

I just came across this thread. Have a belief that my little human brain is faster and wider than computer nets...... i tried using NN but results have been disappointing. Nothing personal, but maybe some other technical means are better?
 
Hi Lurenceli,

You can see "Neural Network Design Live Cycle" attached on this thread, if you get a disappointing result means you should modify/correct any of part.

My self, to improve my understanding at least I read some books about neural network or other Artificial Intelligence tools.

Nothings seems easier but when I am failed means I learn something.
 
Hi,

I am really enjoying the benefit using NSpredictor and NSDT 6, the combination of these software can reach the ideal prediction.

The objective is to create macd prediction:
- create network training data (more than 17000 bars of data, 60 minutes XAUUSD)
- Inputs: momentum, price momentum indicators (60 m) and its higher time frame (4 hrs)
- output: 10 bar future of momentum EMA
- Use genetic algorithm (warm and genehunter) optimization in NSpredictor
- import the trained net into nsdt
- create prediction/trading strategy based on trained net
Seem during retrain in NSDT I get overheating on my CPU (all cores are working hard), but the result is good to be considered (almost 0.99 Rsquared and 99% correct sign).

Need to test further on more out of sample data..

cheers
 

Attachments

  • 99% correct sign prediction.png
    99% correct sign prediction.png
    152.3 KB · Views: 1,038
  • Good Prediction.jpg
    Good Prediction.jpg
    267.1 KB · Views: 614
Here my latest indicators screen shots :D
- Upper part aaNeurotrend, to indicate current market on trending/or not: the yellow one indicate trending or sluggish, red and blue cross over for the signal
- Middle part aaNeuroMACD, to indicate long term trend, above zero for bullish and below zero for bearish
- bottom part aaNeuroRSI, for current short term market cycle.

Trade signal is generated when all indicators are in confluence. So far the trade still good.:clap:
Cheers
 

Attachments

  • aaNeuroGold indicators.PNG
    aaNeuroGold indicators.PNG
    38.7 KB · Views: 1,624
Top