The signal to go long is when the 5 ema of the closes exceeds the 5 ema of the opens.
The signal to go short is when the 5 ema of the opens exceeds the 5 ema of the closes.
Both the long and the short signals will generate 2 orders a few seconds after they are received.
The 2 orders will have identical entry points but they will differ in exit strategies.
The first order, called the X portion, will exit on a Take Profit of 15 pips or on an ema reversal, whichever is the soonest.
The second order, called the Y portion will exit on the ema reversal or on a trailing stop of 30 pips after a paper profit of 60 pips is achieved.
THE ALTERNATING EMA
If the X portion of the trade is signaled to be activated without the 15 pip profit being attained then the E A will recompute the moving average from an 5 ema to a 10 ema. If the new ema still indicates a reversal then the Long (or Short) will be closed and 2 new orders (X and Y) will be generated. If a reversal is not dictated by the new ema then the current position will be maintained.
The 10 ema will now be used for future trades until the next time the X portion of the trade fails to achieve the 15 pips Take Profit. Then the E A will recompute the moving average from 10 ema to 5 ema. The moving average will then alternate between 5 and 10 on each subsequent failure of the X portion to achieve 15 pips
An emergency Stop Loss of 100 pips should be included in the E A.
The respective ema's and all of the pip values should be input variables.