Two MA one RS I
This is a powerful addition to your MetaTrader 5 toolkit designed to optimize market analysis and performance. This Expert Advisor serves as automated trading software. It is utilized to monitor financial markets and execute trades based on predefined algorithmic rules, enabling precise position management without the need for constant manual oversight.
How to Setup and Use Two MA one RS I
1. Installation: Open the "File" menu, select "Open Data Folder," navigate to MQL/Experts, paste your file, and restart the terminal.
2. Activation: Drag the EA from the Navigator onto a chart, ensure "Allow live trading" is checked in the Common tab, and verify the AutoTrading button is green.
3. Optimization: Right-click your chart, choose "Expert List," click "Properties" to adjust inputs, and save your preferred setup as a set file for future use.
4. Maintenance: Regularly check the "Experts" tab in the terminal window to monitor trade logs and potential execution errors.
Frequently Asked Questions
Q: Why is my EA not opening trades? A: Check the "AutoTrading" button, ensure "Allow live trading" is enabled, and verify your broker allows automated trading on your account type.
Q: Can I run multiple EAs on one chart? A: No, each chart can only host one active EA; however, you can open multiple charts for different currency pairs to run several EAs.
Q: What does the "smiley face" icon mean? A: A smiley face in the top-right corner of the chart indicates the EA is successfully running; a frowny face means it is disabled.
Description & Settings
Idea by
: .
MQL5 code by
: .
The EA trades on two indicators iMA (Moving Average, MA) and one iRSI (Relative Strength Index, RSI). Decision on trade signals is only made when a new bar appears, while positions are trailed and closed (in case of profit) at every tick.
An unconventional solution was applied: The
Slow
indicator averaging period is calculated as the
Fast
averaging period multiplied by two, while the
RSI
averaging period is always equal to the
Fast
averaging period. This reduces the number of parameters in optimization.
You can also optimize absolutely all signs "<" and ">" in the signals identification formula. To do so, its own variables (
InpMoreLessBuy_1
,
InpMoreLessBuy_2
,
InpMoreLessBuy_3
,
InpMoreLessSell_1
,
InpMoreLessSell_2
, and
InpMoreLessSell_3
) are introduced. With these variables, the formula is modified as follows:
Input parameters
Parameters of indicators Moving Average:
Fast: av. period
- Averaging period of Moving Average "Fast";
Fast: horizontal shift
- Horizontal shift of Moving Average "Fast";
Fast: type of price
- Price type of Moving Average "Fast";
Slow: horizontal shift
- Horizontal shift of Moving Average "Slow";
Slow: type of price
- Price type of Moving Average "Slow";
Fast and Slow: smoothing type
- Averaging type (a common parameter for "Fast" and "Slow").
Parameters of indicator RSI and of its signals:
RSI: type of price
- Price type of indicator RSI;
RSI: level UP
- UP level of indicator RSI;
RSI: level DOWN
- DOWN level of indicator RSI.
Trading parameters:
Stop Loss
- Stop Loss (if set to zero, the parameter will be disabled);
Take Profit
- Take Profit (if set to zero, the parameter will be disabled);
Trailing Stop
- Trailing (if set to zero, the parameter will be disabled);
Trailing Step
- trailing step;
Lots
- trading with a permanent lot size (parameter
Lots
is above zero and parameter
Risk
is equal to zero);
Risk
- lot size is calculated dynamically (parameter
Risk
is above zero and parameter
Lots
is equal to zero);
Maximum number of positions in one direction
- the maximum number in one direction (if set to zero, the parameter will be disabled);
Close all positions when profit is achieved
- Closing positions at reaching the profit (if set to zero, the parameter will be disabled);
Close opposite positions
- Closing opposite positions (if set to "false," the parameter will be disabled);
magic number
- unique identifier for the EA.
As you can see, along with setting up the parameters of the indicators, this EA allows flexibly setting up (and disabling) Stop Loss, Take Profit, Trailing, the maximum number of positions opened in one direction, closing positions at gaining profit, and closing opposite positions. You can also manage the calculations of position volume: You can trade with a permanent lot size (
Lots
above zero and
Risk
equal to zero), or the lot size can be calculated dynamically (
Risk
above zero and
Lots
equal to zero).
Recommendations on optimization
In the "OHLC на M1" mode, select a symbol and timeframe M15. Disable (set to zero) Stop Loss, Take Profit, and Trailing and set the maximum number of positions in each direction to "1." Or copy to the MQL5\Profiles\Tester\ folder the
Two MA one RSI M15 Start.set
file that already contains the initial optimization parameters for M15.
Select the type of optimization as "Fast (genetic algorithm)" and parameter "Balance max" to be optimized.
For optimization, I recommend to involve : For USDJPY over the year 2017, optimization in the cloud plus my quad-core laptop
took
and cost $0.08.