Build Neural Network Indicator in MT4 using Neuroshell

Hallo Mas Sgr,

I have tested my own neuroMACD based on Back Propagation net vs Recurrent Net, the training result and indicator values are different but not repainted and both of them generate same signal almost at the same time.

I will have a look for your data.
 

Attachments

  • Training Net01 BP vs Recurrent N07.png
    Training Net01 BP vs Recurrent N07.png
    138.2 KB · Views: 497
  • aaneuroMACD N01 vs N07.png
    aaneuroMACD N01 vs N07.png
    52 KB · Views: 544
Hi Sgr,

Please find here my own trained net and implemented chart, all are using your data.

Based on your data I do not know what instrument pair and the output that you try to predict but I just assume that you try to predict MACD and I implemented on XAUDUSD.

Please tell me what is the pair and output prediction, if it is not XAUUSD then I conclude that the net is applicable for other pairs.
 

Attachments

  • SGRMACD1.png
    SGRMACD1.png
    32.1 KB · Views: 464
  • SGRMACD2.png
    SGRMACD2.png
    55 KB · Views: 308
  • SGRMACD training.png
    SGRMACD training.png
    203.1 KB · Views: 457
Last edited:
And here you can compare the indicator result based on your data and my own data..either inputs, output and pair data used should impact the quality of prediction
 

Attachments

  • SGR vs neuro MACD.png
    SGR vs neuro MACD.png
    49.5 KB · Views: 2,203
Hi Mas Arryex,
I tried to predict MACD on EU TF 4H. Below I attach indicator output value screenshots for both of networks. The left one is back propagation and the right one is recurrent network. The top one is running value, while the bottom one is static value. On the back propagation, both the running value and static indicate identical value, while on recurrent network indicate slightly different value (repaint). On recurrent network, the OOS R square is quite intriguing, though :)
 

Attachments

  • net2.PNG
    net2.PNG
    17.9 KB · Views: 312
  • net.PNG
    net.PNG
    21.9 KB · Views: 285
Last edited:
I quote from Wikipedia:
...This special case of the basic architecture below was employed by Jeff Elman. A three-layer network is used, with the addition of a set of "context units" in the input layer. There are connections from the middle (hidden) layer to these context units fixed with a weight of one.[3] At each time step, the input is propagated in a standard feed-forward fashion, and then a learning rule is applied. The fixed back connections result in the context units always maintaining a copy of the previous values of the hidden units (since they propagate over the connections before the learning rule is applied). Thus the network can maintain a sort of state, allowing it to perform such tasks as sequence-prediction that are beyond the power of a standard multilayer perceptron...

The input sequence does matter in recurrent network like Elman network, and current output impacts previous outputs. See the diagram. I think it explains previous repaint behavior as I noted.
 

Attachments

  • 542px-Elman_srnn.png
    542px-Elman_srnn.png
    96.9 KB · Views: 350
If we refer also to the manual: A recurrent network may respond to the same input pattern differently at different times, depending upon the patterns that have been presented as inputs just previously.
Recurrent networks are trained the same as standard back propagation networks except that patterns must always be presented in the same order; random selection is not allowed.

So, we shall not use the same training pattern in wards net into recurrent network. Recurrent network shall not use random selection during data extraction. If we did it then our net will not presenting the input by sequent.

I will retry to retrain with different method
 
I did retrain in different way, but not using an extensive training (only 14 second training time) to get R-squared above 0.94.

When implemented in EU 4H, it give better earlier cross over below and above 0 with each MACD signal about 5 bar in advance. May be your output is next 5 bar of MACD values, am I right?

Three indicators below price chart indicate the previous recurrent net (n07 with random data extraction), below chart is recurrent with sequential data extraction (n071) and the lowest is original MACD.

I do not think this is a repaint, repaint only if the previous result are changed after new values come. The correct word may be too much noise/not smooth predicted result.

You can still improve the prediction result to minimize the ripple and unnecessary cross over.
 

Attachments

  • SGRMACD training n071.png
    SGRMACD training n071.png
    100.4 KB · Views: 395
  • SGRMACD2 a.png
    SGRMACD2 a.png
    55 KB · Views: 466
Thanks Arryex,
It's quite interesting observation. It's true that it should predict 5 bars ahead.
However, I still believe that recurrent network is potentially repaint. It's true for example, by using indi code I sent you we can avoid repainting effect on running price. But the actual prediction result will be rippler than what we see on training result (see previous running value vs static value image), it means that the actual R squared is lower than the R squared we see on the training.
If you curious to what I meant, just try to uncommented the if(counted_bars>0) counted_bars--; on the indi code. In MT4, run any EA on visual mode then attach the indi on the running price. You will see on the indi that the last two bars will be dancing. It won't happen if we use back propagation with the same code, where only the last bar will be dancing.
 
Hi SGR,

Please recheck your data, after reviewing it your data is sorted from the recent to the old, i.e. 2010.01.25 16:00:00 down to 2010.01.21 16:00:00.

It means you use NN to train to predict the older data instead future data, I think you should rearrange your training data then the recent one shall be at the bottom. With this way then your net will be valid.

I will have a look to my rearranged data.
 
Hi Sgr,

You are correct, I found also that the last bar of predicted value using Recurrent nets is repainted (changed as the price change).
I think this happened because recurrent net will use the previous result as input for the next prediction and compare with the current error (predicted - actual).
I already try also to add more lag as input instead of current value, the result also same, the last bar is repainted. For your info, after resorting the data, the R-squared value is less than previous result (0nly 0.85 for less than 1 minute training).
I do not know yet how to avoid this ..but thanks for a good finding ..
 
Hi Arryex,
I also get lower R squared when I rotate the pat file. Btw, do you notice the confirmation message box appearance (see image) everytime we choose recurrent network? Does it mean NS2 automatically rotate the pat file? If it so, then we don't need to manually rotate the pat file.
On some literatur recurrent network is suitable for pattern recognition, but I don't have any idea how to implement it over time series data, yet. My conclusion for the time being is that recurrent network prediction result is potentially repaint. We can avoid the repaint problem, but we will get more ripple result.
 

Attachments

  • net3.PNG
    net3.PNG
    7.8 KB · Views: 234
Hi Sgr,

I do not receive that message when using your original file.

Here is the result after resorting (from the old to the newest one). The R-squared is worst than before and predicted indicator as well.
 

Attachments

  • after resorted.png
    after resorted.png
    58.9 KB · Views: 359
Here is the note for recurrent net (from Help):
"You must use rotational pattern selection for both your training set and test set when working with recurrent networks. When training the network it must have the patterns presented in sequence without gaps in the data. You must also test the network with the patterns in sequence. "

Anyway, when you select Jordan Elman Net, the option for random is disabled by default either using momentum or turboprop. So the important thing is your data shall be in proper sequence and No Gaps.
 
Hi!

Sorry guys maybe somebody here can help me.

I have a sequence of double values in a text file like this:

1.522
2.033
3.568
4.999

etc.

How can I read them in Mt4, and display them as values of an indicator?
Does anyone as a sample, or a template?

Thanks for any help.
 
Hi Superluz,

I remember last time I did to display the COT values which are saved in csv format and load them as indicator. Sorry forget where I saved it, I try to find but not succeed.

Try to search with google to find "COT indicator", the principle looks like the same, you save a calculated value in a file and display them as indicator.

Hope can help you
 
Currently, I have problem with my broker,
1. I have open buy with take profit but can not be fulfilled. There is no guarantee that the order (to close open position) will be executed.
2. Several times OFF Quote, so can not close open position until profit position turning to loss position. No problem to close any loss position
3. The spread change widely and uncontrolled, as the impact:
- Any stop, limit position which are against the market trend can not be fulfilled
- Any take profit can not be fulfilled
4. Seems this broker against my position, he gets widely profit due to adjusting spread, Off quotes to counter client position.
Most of time not easy to close any profit position until turning to lost position.
5. Another broker, request to adjusting the margin since it is required during volatile market, otherwise any open position will be cut directly (as lost).

If you have similar experience with them, please explain here..I have two brokers name..I will shown if somebody also posting his broker problem.

Stay away from these Brokers..
 
Currently, I have problem with my broker,
1. I have open buy with take profit but can not be fulfilled. There is no guarantee that the order (to close open position) will be executed.
2. Several times OFF Quote, so can not close open position until profit position turning to loss position. No problem to close any loss position
3. The spread change widely and uncontrolled, as the impact:
- Any stop, limit position which are against the market trend can not be fulfilled
- Any take profit can not be fulfilled
4. Seems this broker against my position, he gets widely profit due to adjusting spread, Off quotes to counter client position.
Most of time not easy to close any profit position until turning to lost position.
5. Another broker, request to adjusting the margin since it is required during volatile market, otherwise any open position will be cut directly (as lost).

If you have similar experience with them, please explain here..I have two brokers name..I will shown if somebody also posting his broker problem.

Stay away from these Brokers..


Arry

I have been in the FX industry for couple fo years now. you are correct to mention that the broker may be trading against you, this is true with small brokerage houses . This is because your trades are not passed on to market and your system is profitable.

Its better you can disclose your broker here i can give you feedback. With regards to spreads becoming wide this can be done by switching you to a profile where you account picks up higher spreads and manual dealer intervention.

Again sorry to hear this, the solution is here

You trade with broker who offers STP (staright through processing) technology where the trades get passed on to the OTC liquidity pool. I know a very good STP FX broker who offers mt4 but not gold for now.

Also when you use stp the spreads are market spreads so in volatile times spreads widen..:)
 
Supremegizmo,

For the moment I am closing my account first afterward I will disclose the brokers name.

Thanks for your advice..
 
Top