Moving average
-
Greetings,
I would like to create an EA where there are 3 moving averages.
The conditions are the following.First off, we have 2 Moving Average that move in pairs; the 200 High Exponential Moving Average and the 200 Low Exponential Moving Average. If both moving averages are above the 800 Opening Simple Moving Average, then the interest is to open only buy position. If both moving averages are below the 800 Opening Simple Moving Average, then the interest is to open a sell position. In simple terms where both moving averages are found, will determine what future position will be taken. Kindly note that if only one of the moving averages are found in either side, then no position shall be take; either both moving averages are found on one side or no position will be taken.
After we have determined what kind of position we have interest in opening, we have to identify our entry points. If we have interest in selling, then I want the EA to open a selling position when price closes under the 200 Low Exponential Moving Average. If we have interest in buying, then I want the EA to open a buy position when price closes above the 200 High Exponential Moving Average.
Assumingly we opened a selling position, the closing condition will be when price closes above the 200 High Exponential Moving Average. If we open a buy position, the closing condition will be when price closes below the 200 Low Exponential Moving Average.
Kindly notice the entry position is reliant on where both 200 Exponential Moving Average is found, but the closing position is not. Position are opened only once for every time the condition is met.
- Just a side note, I would like to add a condition where if spread is more than one then we have interest in opening a position (the number of spread must be adjustable).
Below you can find the shared project:
https://fxdreema.com/shared/B9sUTxV6e
Your response is much appreciated.
-
@ramimoujaes This is what I recommend:
- Specify candle ID 1 on all operands of all 'condition' blocks.
- Connect blocks 5 and 9 below blocks 3 and 7 respectively and not below both 'Close trades' blocks.
What do you mean by 'spread is more than one'? What do you want a higher spread?
-
Greetings @l-andorrà
I want you to take a look at the picture below:

As you can see in the picture above, it opened correctly the selling position; because the pair of 200 EMA's are below the 800 EMA, and price closed below the 200 Low EMA. But it should close the position when price closed above the 200 high EMA, which it did not do.
Below you will find the shared project.
https://fxdreema.com/shared/jeJlMvkW
*I did the candle ID'S as per your advice, and I adjusted the blocks based on your advice.
*You can forget about the concept of spread, It won't be in my strategy or EA
Your response is much appreciated
-
@ramimoujaes Then remove both 'close trades' blocks from its current positions a create a new separated tree with the closin conditions headed by a 'For eachtrade' block like this:

One is for buys and the other for sells.