Neural Network EMA system (NeuroTrend)

Hi Everyone,

After a lot of research, reading excellent basics at babypips and experimenting with various systems, I have finally implemented a forecasting system based on Neural Networks. Neural networks based systems are proven in financial forecasting and in general in learning patterns of a non-linear systems.

I believe strongly that forex market is a non-linear system which is difficult to model. But one good thing of forex market is that it represents some patterns which when known can be applied in making trading decisions. Proof of this concept is technical analysis and theories that are widely used by traders in identifying these patterns. This makes neural networks a better tool for forex market as neural networks are know their ability of learning unknown processes and forecast the patterns of the process ahead.

Lets get to the main point. In this thread I would describe the working of the system I have developed rather than the system itself as it is a long way to explain. The system is basically a time-series-forecasting system, which means we give as input information about current Bar and the system would give out information about Bars in future. I am sure now you are thinking if its really possible and if so what are the actual inputs and what are the actual outputs. I would strongly suggest the reader to go through the basics of neural networks before reading further.

[B]An Introduction to Neural Networks forecasting[/B]

Note: The system is optimized and targeted to trade on EURUSD 15min chart


EMA(t) - EMA (t-1)

EMA(t-1) - EMA (t-2)

EMA(t-2) - EMA (t-3)









1H EMA(t)

1H EMA(t-1)


EMA(t) - EMA(t+1)

EMA(t+1) - EMA(t+2)

EMA(t+2) - EMA(t+3)

where t means current time or Bar. As you see, we give the difference of the past three EMA of the 15min chart Bars, past two indicator values of RSI, %R, MACD, Stochastic and past two EMA difference of 1H chart Bars. The system will be able to forecast and output the future 3 EMA difference of 15min chart Bars. How is this able to forecast is hard to explain (may be I will start a second thread), but for now you should consider the system is able to do so as it has been trained on several past data (3-6 months). The system for now consists of an indicator and an include file (both attached at the end). I would be showing some examples how it can be used to detect the patterns of forex market and make trading decisions.

Dashed Aqua blue line (bottom most): EMA 5 bar

Yellow line: Forecasted EMA(t+1) / output 1 of neural network

Green Yellow line: Forecasted EMA(t+2) / output 2 of neural network

Gold line (top most): Forecasted EMA(t+3) / output 3 of neural network

In the figure above it is clear from the forecast lines that the trend is going to be Bullish eventhough the current EMA shows Bearish trend. This is a kind of lead indicator.


  1. All three forecasts significantly above current EMA

  2. RSI trending up from below 50 level and about or crossed 50 upwards

  3. Stochastic Main > Signal and trending up from over sold region

  4. Optional: MACD going negative to positive



  1. All three forecasts significantly below current EMA

  2. RSI trending down from above50 level and about or crossed 50 downwards

  3. Stochastic Main < Signal and trending down from overbought region

  4. Optional: MACD going positive to negative



Please read the Instructions.txt file in the zip file attached below. A step by step procedure to install the NeuroTrend is documented in the file. If you find difficulty in installation do not hesitate to ask me…

Finally I would like to say that have fun with the system and if you like it do comment. If you have ideas or suggestions to apply it or adapt it, share it in this thread. My main aim in making it open to this forum is to get experts suggestions and improve it and learn from the experience of its applications…of course also earn a couple of bucks hehehehe

Note: Due to file attachment limitation, the actual files are zipped to NeuroTrendv1.0

Aroon (21.4 KB)

Pretty cool system…What is your exit strategy?


Exit strategy for long is when the dashed EMA5 line moving up and crossing the forecast signals or all the signals come together with no significant difference. For short its the opposite ie… the dashed EMA5 line moving down and crossing the forecast signals or all the signals come together with no significant difference.

Stop loss: For long, recent swing low or 20pips below. For short, recent swing high or 20pips above.

Best Wishes,

how well does your system work?

I cannot give quantitative results as I did not trade live with the system. I am currently testing it with a demo and live account. I would publish as soon as I have significant results. I am seeking also interested people to join me and
give valuable feedback to optimize the system.

I would suggest interested people to load the forecasting system and see how it is able to forecast the future signals. In my opinion this is a kind of [B]lead[/B] indicator every trader is looking for.

I have been doing a lot research to program a forecasting system based on neural networks and tried various methods. The final best output of my effort is NeuroTrend. I am open to explain in detail how neural networks work, architecture of the system, and how to train such systems in return to suggestions, testing results and valuable feedback.


i think demarker indicator is better version of the rsi. maybe you can also need think about sideways market and how your system would predict that!!! if small sideways movement.

Hi … I saved the template and indicators to the correct folders (I’ve had a lot of experience installing indicators and templates) but when I load the template, the indicators are not listed on it and also the Neuro Trend Indicator is not in the indicators list even though it is in the indicators folder.

Any suggestions?

The reason for not loading properly would be not able to find the ex4 file in the folder. You need to open the NeuroTrend_indicator.mq4 in editor and compile once so that the ex4 (executable) is created and then load the template. I think restarting the terminal should do this automatically.

If it does’nt help tell me I would recheck it on my system and send the ex4 files if needed.

Best Wishes,

Thanks for the suggestion, I can test it by adding also Demarker indicator as one of the inputs. My intention to use RSI was only as a trend confirmation tool. I should also read about Demarker. I have never used it.

Concerning sideways, the indicator is right now able to be quite when the market is moving side ways (absolute). Any better suggestions (indicators) to improve the side way pattern detection?

Also neural networks are capable of learning any pattern that has to be detected unless and until the model is define well and the inputs given have this information. In my experience with various indicator inputs, I found the currently included indicator inputs work better.

In future I plan to make a table of indicator inputs and their combinations and a comparison of the outputs according to the inputs.

Best Wishes,

I have updated the indicator and template. Following are the new changes.

  1. Email and Alert notification on setup

  2. Small chages to the colors of the levels

Download the new version from the attachments

are you trying make ea based on it. i think it is important to understand relationship of time because thats when markets are you usually quiet.

Yes I plan to program an EA based on NeuroTrend indicator, but I would do that only after I have a well optimized neural network forecaster. If I start to program an EA right in the initial phase I would loose my concentration on the model and the parameters for the network to better forecast.

to be honest with you i am interested in neural networks but to be frank I dnt know anything about them. This thread is so confusing to me is there anyway that you can give me a basic breakdown of what neural networks are and how it relates to your system.

I hope you don’t misunderstand me i never mean to insult you I just feel lost in your beginning posts and if you could put it in “laymens terms” I might have half of a chance at understanding it.
Thanks, John

Hi John,

In this reply I would, in short, try to explain what a neural network is and how it is applied for financial and business forecasting.

By definition, neural networks simulate biological network of human brain. Means they act and try to learn and perceive things as done by the neurons in the human brain.

In simple words for me a neural network is a [B]black box[/B] which has some [B]inputs[/B] and some [B]outputs[/B]. Now let us assume that this black box has a [B]memory power[/B] inside it. And also assume that if we feed this black box with prior known inputs and prior known outputs, the memory power of the black box is capable of learning both the inputs and outputs. By inputs and outputs here I mean numbers.

Now let us say we have a system which we want to learn. In our case we want the black box to learn the price changes of forex market. So forex is for us a non-linear market which cannot be modeled. By modeling I mean one cannot say how the prices change and what influences the prices. But we assume that it has some [B]patterns[/B] that repeat or can be identified like bullish trend, bearish trend, Elliot wave pattern, flag, triangle, etc…

How the memory power works is strongly dependent on the design of the neural network, what (patterns) are aimed to learn and how well the inputs are selected for the outputs that the blackbox has to produce.

Now I will explain how neural networks relate to the system (NeuroTrend) I have designed.

Note the following notation. It is opposite to the mql notation, but this will make us understand things easier.

t: time of the current candle / Bar
t+1: time of the next candle / Bar
t-1: time of the previous candle / Bar
t+n: time of the future nth candle / Bar
t-n: time of the past nth candle / Bar

Now with this notation lets see some examples

EMA(t) = current EMA = EMA with shift 0 = iMA(NULL,PERIOD_M15,5,0,MODE_EMA,PRICE_CLOSE,0);

NeuralTrend is a neural network system which is designed to learn the forex market movements and forecast it. Lets see the design of this neural network.

Once we have designed our network, ie. what are our outputs, inputs and how many elements is the network composed of, we are ready to train it.

What I did is collected data of previous [B]2-6 months[/B] and trained the network. During training the outputs are also history data and inputs are also history data but not the same. Ex: if my outputs are [B]EMA(t-1), EMA(t-2) and EMA(t-3) inputs must be values of indicators of (t-4) or before[/B]. The main usage of the neural networks is only after training.


Since we trained our network with history data, it has learnt the patterns that are represented in the training data. Now, if we give some inputs to the network, it should be able to give outputs according to the given inputs and based on how well it has learnt patterns in training phase. In NeuroTrend if we give[B] current candle/Bar EMA[/B] and [B]other few commonly used indicators as inputs[/B], [B]NeuroTrend forecasts the EMA for the next 3 periods ie the future Bars[/B]. It is able to do so as it has learnt the patterns of the forex market. Knowing the future EMA we can estimate the what the price would be and can make decisions to buy or sell.

Example: In robotics, a robot neural network gets inputs from various sensors (temperature, pressure, position, objects in view). The neural network provides according outputs for the robot to act.

In reality, a neural network is more than just a black box and I have to dive into programming in order to explain logic behind it which would be a long topic for this reply. In coming weeks, I would introduce day by day to the actual neural network logic and examples by mql code. The code for creation of a neural network and usage is in the include file(NeuroTrend_Include.mqh) which is also used by the NeuroTrend_Indicator.

I hope I have explained in short what a neural network is, how it is trained, and how it is applied in forecasting. Neural networks are widely used in Buisiness, financial, weather, non-linear processes forecasting due to their ability to learn unknown processes. Once taught with history data neural networks are used to know the future values and act accordingly. For a detailed explanation I would suggest to go through (only introduction) the following online tutorials.

Neural Network Tutorial

Neural Networks

Introduction to Neural Networks

Widely used application: Neural networks is also used to detect hand written characters on touchpads, PDA, etc… In the following link one can write characters and test how the network is able to detect.

OCHRE- Optical Character Recognition

Finally I would say that it is not hard to learn Neural Networks and apply, only it is a bit dry topic and needs attention. I learnt it myself and am confident of its ability in forecasting.

[B]To the main thread about NeuroTrend and downloads[/B]

Best Wishes,

Wow!!! fantastic post. I get it now. So you are saying that based on price movements of the past the nn (neural network) will be able to churn out a future price. So in a way it is a program that seeks to trade like many people do in that we look at indicators which show past price movement and we try to (ugly word) predict future movements. The reason I like the nn as it is applied here is it is mathamaticaly correct and that can be good. (no trading on a whim) If an nn was able to give us a “realtime” indicator wow that could be pretty powerful stuff.
Excellent work so far. Im definatly interested and when I have some time i will read your links on nn basics.
thanks, john

I just downloaded and installed the files. In the demo-version it looks very promising. Will test it live on Monday for sure.

Thanks, Aroonray for all your efforts and for sharing your ideas!

Best regards


I think you should add an indicator like an arrow for up/down so you can see where it has been triggered, otherwise you cant tell without examining it all very closely.

Hi John,

You got it right. Exactly as you said [B]a well trained neural network is like a highly experienced trader who can easily catch the market movements. He does it as he has been trading for a while and learning these patterns of the forex market.[/B]

But to be frank it is also not so easy to design a neural network. It all depends on what parameters (inputs and outputs) are chosen for forecasting a specific pattern. This is why I want to discuss this topic so that I get valuable feedback from the experienced traders. If we ask about RSI or MACD or Stoch to different traders, we get also different answers how they use them and for what purpose they use them. Example some use RSI for trend confirmation and others for support and resistance.

After a lot of trial and error attempts the current Neural Network indicator (NeuroTrend) is able to forecast trend changes. But I don’t say it is highly accurate and it can forecast all the time 100% correct. This will strongly depend on the training.

Best Wishes,

Hi Andreas,

Nice to know that you see it promising. Do post your experience and suggestions for further development. Do let me know how you use it in your trade.

Best Wishes,

In the latest version you get an alert and also email if a signal is triggered. Nevertheless the idea of showing an arrow would be helpful.

Thanks for the suggestion,