# Double Moving Average tfmt4

This is a 2 moving average system that is not in the market all the time. Entries occur in the direction of the MA cross when the price closes to the outside of the faster moving average. Positions exit when the price closes back on the inside of the faster moving average.

**Note:** The default input values are not optimized. Demo the EA and adjust the inputs to find the optimized combination for your risk tolerance and to maximize profitability. Trend Following systems are designed around long term probabilities. Although Trend Following systems have lower win rates, profitability comes from large trends as Trend Following cuts losses short and lets winners run. Test on a portfolio of symbols as profits from trending symbols will offset the small losses and provide profits when other symbols are not trending.

### Entries and Pyramiding

Entry criteria checks the direction of the moving average cross, checks that the bar is completely outside of the fast moving average, and confirms that the previous bar's fast moving average has improved over the moving average of the bar before. If you set the Max Unit variable above 1, additional entries will occur and pyramid in ATR increments specified by the ATR between Pyramids variable.

### Exits

This expert advisor closes its positions when the price closes back inside the fast moving average to the side of the slower moving average.

### Position Sizing and Stops

This EA calculates the position sizing using the Percent Volatility method which is directly tied to the stop. The stop uses the ATR_Periods and Stop_Range_ATR inputs to calculate the ATR and then multiply the two values to set the stop distance from the entry price. Stops are not coded into the position but this EA closes out the position if the price reaches the stop value. As additional units are added through pyramiding, the stop moves to correspond to the latest entry price. Using the stop value, the Risk_Percent input, and your account information (tick size, lot size, digits, etc.), the position sizing uses the monetary value of the distance from entry to stop and keeps the number of lots limited to the percentage you specify. This allows every symbol, price, volatility to be treated equally. As your account size changes through profits or drawdowns, the position sizing will account for the change.

### Inputs

**Short_MA**—The number of bars used to create the faster moving (less bars) simple moving average.**Long_MA**—The number of bars used to create the slower moving (more bars) simple moving average.**Risk_Percent**—The percent risked per position if the price reaches the stop. Example: If you want 2% of your equity to be risked per position, enter 2 to this input.**ATR_Periods**—The number of bars to use in the ATR calculation.**Stop_Range_ATR**—This value will be multiplied by the ATR to determine where the stop will be from the entry price. Example: If you want your stop to be set at 2* ATR from the price, enter 2 to this input.**Max_Units**—The maximum number of entries (including the initial entry) as the position gains profits and the EA adds pyramid positions.**ATR_between_Pyramids**—This value will be multiplied by the ATR to use for calculating when to add the next position through pyramiding. Example: Set this to 1.5 and the next pyramid position would be added when the price reaches your entry plus ( 1.5 * ATR ) for long positions or entry minus ( 1.5 * ATR ) for short positions.**Slippage**—Amount of allowable slippage when entering position.**Reduction_Percent**—Enter an amount by which to reduce your equity for the position sizing calculation. Example: If you are in a drawdown period you can enter 20 to this input and the position size will be 20% less than without the reduction. The position sizing calculation would treat your equity as 80% of what it really is to lower your risk until the drawdown is over.