The development of the final strategy was done as it was demonstrated in the previous
section. All the step by step additions of components and tests helped the strategy to
become more robust and trustful.
Summary of Strategy Conditions
All of the following conditions must be satisfied for the system to enter the market.
- Fast EMA crosses over (for long entry) or under (for short entry) Slow EMA.
- Price must be above (for long entry) or below (for short entry) the EMA 50.
- The slope of the EMA 50 must be positive (for long entry) or negative (for short
- If all of the previous conditions are met the system enters the market in the next bar
when the price reaches the highest high (for long entry) or lowest low (for short
entry) of the previously defined number of bars back.
- The system always enters the market with a fixed position sizing equivalent to
- Whenever one of the following conditions is met the system exits the market.
- Fast EMA crosses the Slow EMA in the opposite direction than when the system
entered the market. In this case, the system sells in the next bar at the highest high
or lowest low price of the previously defined number of bars back for each.
- The opened position reaches the stop loss amount.
- The opened position reaches the profit target trailing amount and then the price
falls back the specified percentage that activates the stop.
Two EMAs, fast and slow, have to cross each other to enter and exit the market.
Final Strategy Components
In the following section, the components of the final strategy will be explained in detail.
The final strategy, as well as all the previous strategies, uses 60 minute bars. There were several factors that were involved when choosing this length for the bar. The most important one was because with 60 minute bars the markets do not oscillate as much as they do in the smaller lengths bars. Bars with smaller lengths show too much noise in the market, making excessive oscillations provoking frequent entries and exits which make the system less profitable. Figure 32 shows the length of the bar that is being used for the Final Strategy.
Figure: Example of the length of the bar
Fast and Slow Exponential Moving Averages
The most important indicator used for this strategy was the Exponential Moving Average (EMA), because the decisions to enter the market are made by the crossing of a fast and a slow EMA which show changes in momentum. EMAs are good indicators of long term trend
and changes in momentum that help to notice when the trend of a market is finishing and when there is another trend starting in different direction. In this strategy, the fast and the slow EMAs need to cross in order to enter a market.
Figure: Example of the EMAs
Figure shows the three EMAs used for this strategy. The fast and the slow EMA are used to detect changes in momentum with their crosses. The use of the EMA 50 will be explained in the EMA 50 and Slope section.
The trigger lengths are the numbers of bars back considered for any condition. In this particular case, the trigger lengths define the number of bars back taken in account for the highest-high or lowest-low prices required to enter or exit a market. The strategy only buys or sells the next bar after an EMA cross, only if the market price arrives to the highest high (for long entry) or lowest low (for short entry) of a predefined number of bars back; this helps to prevent the robot from entering a position after a cross when the market is immediately going in the opposite direction. For a better performance, these lengths have been separated as individual variables, meaning that there will be trigger length for long entry, short entry, and a trigger to exit a long position, and another to exit a short position. The variables were made this way because the results obtained by using different variables compared to using single variables, trigger length for long and trigger length for short, were significantly better and also gave the trader more control over this condition.
Trailing Stops and Maximum Loss Stop Amount
As it was discussed in the previous section, stop loss helps to have control over the maximum loss that the trader is willing to accept before closing a position. The trailing stops in this strategy work similar to a profit target; when the price reaches the profit target specified by the “floor amount” it activates a trailing stop using a predefined percentage so that if the price keeps on going in a profitable direction, the strategy holds the position, but if the price goes in a negative direction for a value higher than the “trailing percentage” it closes the position. The variables that have to be chosen for these conditions are: floor amount and trailing percentage, for trailing stop.
EMA50 and Slope
The EMA50 and slope are two conditions that were added to the strategy to make it more robust. The EMA 50 is a good benchmark to compare with the market price; if the trend is going up and the market price is higher than the 50 EMA it is a good sign to go long, if the trend is going down and the market price is below the 50 EMA it is a good sign to go short. In order to enter a market, the two EMAs have to cross each other and also the price has to be higher (for long entry) or lower (for short entry) than the EMA 50 and the slope of the EMA 50 has to be positive or negative, respectively. The addition of the EMA 50 and the slope conditions was made to make the entries be executed only when the changes in momentum are in the same direction as the long term trend.
The slope that is used in the strategy is based on a linear regression applied to the EMA50. This slope works as a condition to enter the market; this means that if the slope is positive, the position opened should be long, and if the slope is negative, the position should be short. This is just a trend confirmation condition because it helps to prevent entering the market against the trend, which will most likely lead to loses. The only variable for this condition is the number of bars considered to do the linear regression.