Mastering MA MACD Position Averaging with MetaTrader 5

Mike 2018.12.28 21:56 34 0 0
Attachments

Idea by: Myth63

Code mq5 by: barabashkakvn

The EA is designed to evaluate trading signals or consider adding to an existing position only when a new bar forms.

This Expert Advisor (EA) utilizes the iMA (Moving Average) and iMACD (Moving Average Convergence/Divergence) indicators. If an open position incurs a loss greater than the Step Loss in pips, it will trigger an additional position to be opened in the same direction of the loss, with a larger lot size determined by the Lot Coefficient.

The EA can manage either a single position or multiple positions in the same direction. It features two key parameters: Indent Price from MA and Ratio of MAIN to SIGNAL, which are illustrated in the image below.

MA MACD Position averaging

For a sample BUY signal: the MACD indicator must be below "0.0", the main line (MAIN) needs to exceed the signal line (SIGNAL), and the current price should be above the Moving Average. Additionally, two filters enhance this condition:

  • Ratio of MAIN to SIGNAL
  • Indent Price from MA

You can choose which bar to analyze—whether it's the current (zero) bar or the previous one (bar #1). This option is set via the Bar Current parameter.


How the EA Works

Upon forming a new bar, the EA gathers data on the number of BUY and SELL positions, as well as the most unprofitable (in terms of pips) BUY and SELL positions. If both BUY and SELL positions exist simultaneously, it triggers an error, leading to the closure of ALL positions. If the most unprofitable position exceeds the Step Loss threshold in pips, the EA retains the parameters for that position, including the ticket number and lot size.

List
Comments 0