Machine Learning Grid Trading Expert Advisor
This Expert Advisor leverages neural network computations with backpropagation for continuous learning and grid trading to achieve cost averaging.
Features
Neural Network Integration: Utilizes a neural network to filter and execute high-probability trades, enhancing decision-making accuracy.
RSI Indicator: Employs the Relative Strength Index (RSI) for precise entry and exit signals, ensuring trades are based on robust technical analysis.
Grid Trading: Implements a grid trading strategy to cost average trades, reducing risk and optimizing entry points across a range of market conditions.
Risk Management: Features adjustable take profit and stop loss levels, along with dynamic lot sizing based on account balance. This ensures that lot sizes increase with a rising account balance and decrease when the account balance falls, maintaining a balanced risk profile.
Optimisation
The following parameters can be adjusted to optimize the EA's performance:
Neural Network Target Values:
Target value for predicting a long entry signal.
Target value for predicting a short entry signal.
Learning Rate: Controlling the speed of weight adjustments during training. A crucial parameter for fine-tuning the neural network's responsiveness and stability.
Coefficient Applied to Weights: Scale the influence of neural network weights, affecting how inputs are transformed into outputs.
Take Profit and Stop Loss Pips: Adjust levels to define the profit and loss limits for each trade.
RSI Lookback Period: Number of bars to consider for RSI calculation, which can be fine-tuned for sensitivity to market movements.
Grid Trading Parameters:
Distance between grid level, determine the spacing of additional trades.
Lot sizing for each grid level trade, aiding in cost averaging
Overbought and Oversold Levels: RSI thresholds for identifying entry and exit points, customizable to suit different market conditions.
Code Snippets:
Neural Network & Backpropagation functions
Neural Network functions
Functionality
Entry Signals:
Long Entry: Initiates a long position when RSIBuffer[2] <= 30 and RSIBuffer[1] < 30, indicating an oversold condition.
Short Entry: Initiates a short position when RSIBuffer[2] >= 70 and RSIBuffer[1] < 70, indicating an overbought condition.
Neural Network:
Processes RSI values through a neural network to filter out low-probability trades and only act on high-probability signals.
Utilizes backpropagation for continuous improvement, adjusting node weights based on prediction errors to enhance the network's accuracy over time.
Grid Trading:
Executes multiple trades at set intervals above and below the current bid/ask price to cost average trades that move in the opposite direction of the initial position.
Exit Signals:
Long Exits: RSI reaches 60 or the predefined stop loss/take profit levels are hit.
Short Exits: RSI reaches 40, or the redefined stop loss/take profit levels are hit.
Code Snippets
OnTick function
Key Takeaways
Combining a neural network and a grid trading system with a traditional technical indicator such as an RSI can be a good way to improve the profitability and the drawdown profile of your trading strategy.
For more information or to discuss your project, shoot me a message on Upwork!