The EA uses three moving averages. A position is opened when all of them move in the same direction. As soon as the fastest moving average crosses the average in the opposite direction, the position is closed. You can choose moving averages with fewer bars to search for short-term trends, or vice versa, increase the number of bars to search for longer-term trends.
Note: the default input values are not optimized. Test the Expert Advisor on a demo and adjust the input parameters according to the acceptable risk and goals. Trend-tracking systems are based on long-term probabilities. Although such systems have lower win rates, profitability comes from large trends, in such systems losses are limited, and profitability is increased. Testing on a portfolio of symbols has shown that gains on trend symbols compensate for small losses and can provide profits when there is no trend for other symbols.
Entrances and pyramid system:
A trade is opened when the fastest moving average is outside the medium-term moving average, and that, in turn, is outside the slowest (see screenshot). If the value of the Max Unit variable is greater than 1, additional inputs and a pyramid with the ATR step specified in the ATR between Pyramids variable will be used.
[spoiler title=”Read More…”]
Outputs:
The position is closed when the fastest moving average crosses the average in the opposite direction. The closed moving averages of the previous bar are used for the exit.
Position and stop size:
The Expert Advisor calculates the position size based on the volatility value, this is directly related to the stops. For stops, the ATR_Periods and Stop_Range_ATR parameters are used to calculate the ATR, which are then multiplied by a certain factor to set the size to the stop level from the opening price. Stops are not encoded in the position, but the EA closes the position when the price reaches the stop value. Since the position volume can increase with the pyramid system, the stops move according to the last entry price. Based on the stop values, the Risk_Percent parameter, and the account information (tick size, lot size, number of decimal places, etc.), the position size selection uses the distance from the entry price to the stop level in monetary terms, and also takes into account the number of lots within the percentage you specified. This allows you to work with any symbols, price and volatility. Since the amount of funds in the account changes, the position size will also be set in accordance with the changes.
Input parameters:
- Short_MA: Number of bars to calculate the fastest simple moving average (minimum number of bars).
- Middle_MA: The number of bars to calculate the medium-term simple moving average.
- Short_MA: The number of bars to calculate the slowest simple moving average (the maximum number of bars).
- Risk_Percent: the percentage of risk for each position at the close of the stop. For example: if the risk percentage should be equal to 2% of the equity, specify 2 in this parameter.
- ATR_Periods: The number of bars to calculate the ATR.
- Stop_Range_ATR: This value will be multiplied by ATR to determine the distance of the stop from the entry price. For example: if the stop should be at a distance of 2*ATR from the price, specify 2 in this parameter.
- Max_Units: the maximum number of position entries (including the very first initial entry) in the pyramid system when the profit on the position increases.
- ATR_between_Pyramids: this value will be multiplied by the ATR and used to calculate when the next position in the pyramid should be added. For example: with a value of 1.5, the next entry in the pyramid system will occur when the price reaches the value of input price plus (1.5 * ATR) for long positions and input price minus (1.5 * ATR) for short positions.
- Slippage: Allowed slippage when entering a position.
- Reduction_Percent: The value by which the equity should be reduced to calculate the position size. For example: during the drawdown period, you can specify 20 in this parameter and the position size will be 20% smaller. The position size calculation function will determine the equity size as 80% of the real value to reduce risks until the drawdown ends.
[/spoiler]