Watch how to download trading robots for free
Find us on Twitter!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Libraries

LSTM Neural Network - library for MetaTrader 5

Shephard Mukachi
Published by:
Shephard Mukachi
Views:
9510
Rating:
(17)
Published:
2019.01.17 20:59
Updated:
2019.05.20 21:45
Gates.mqh (4.3 KB) view
TimeStep.mqh (3.79 KB) view
LSTMNetwork.mqh (11.24 KB) view
LSTMTest.mq5 (3.14 KB) view
Simple RPC.mq5 (9.92 KB) view
Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Attached are the include files for the LSTM. The files included are:

  • Gates - for the 4 gates used in an LSTMs. 
  • TimeStep - which combines the gates, and in practical usage would represent the time series bars.
  • LSTMNetwork - implementing the learning algorithms.

Also included is an example LSTMTest script using the Simple RPC indicator, also attached.

To create a new LSTM network, provide the constructor with number of patterns, number of inputs (predictors per timestep) and the number of timesteps, as shown below;

CLSTMNetwork *net=new LSTMNetwork(patterns,inputs,timesteps);

To teach the network, call the Learn function, providing it with the input array, the targets array, the learning error threshold, and the number of learning epochs as below;

net.Learn(in,tg,mse,500000);

After learning, the final error and epochs taken to converge can be acquired from the network as below;

net.MSE();
net.Epochs();

To check a particular pattern against the network, the Calculate function is called, passing the candidate pattern into the function as a parameter as shown;

net.Calculate(in);

The Calculate function returns the output. This LSTM has a single output neuron.

If anyone finds bugs or has improvements or any suggestions, please be kind enough to share. Good luck.

Trix oscillator with support / resistance lines on chart Trix oscillator with support / resistance lines on chart

Trix oscillator with support / resistance lines on chart

Stochastic with support / resistance levels Stochastic with support / resistance levels

Stochastic with support / resistance levels

Smoothed WPR Smoothed WPR

Smoothed Williams percent range

Smoothed WPR with floating levels Smoothed WPR with floating levels

Smoothed WPR with floating levels