MQL5 Wizard: Trading Signals with Bullish/Bearish Harami and RSI Confirmation
Info
The MQL5 Wizard: Trading Signals with Bullish/Bearish Harami and RSI Confirmation is a Expert Advisor for MetaTrader 5 that this tool allows for the creation of ready-made expert advisors (eas) based on classes provided with the client terminal. It enables quick testing of trading ideas by creating custom trading signal classes.
Usage
This tool is typically used for automated trading on major forex pairs and gold.
Platform
This Expert Advisor works exclusively on MetaTrader 5 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL5/Experts folder via File ? Open Data Folder in MetaTrader 5.
How to Install and Use MQL5 Wizard: Trading Signals with Bullish/Bearish Harami and RSI Confirmation
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.
What this tool does
This tool allows for the creation of ready-made expert advisors (EAs) based on classes provided with the client terminal.
Typical Use Case
This Expert Advisor excels in automated trading and technical analysis on MetaTrader 5.
Compatible Platform & Setup
This Expert Advisor works on MetaTrader 5. Place the file in the MQL5/Experts folder and restart the terminal.
Description & Settings
Related: automated trading with mq l5 wizard: crossover of two exponentially smoothed moving averages - another powerful expert for MetaTrader 5 traders.
This tool allows for the creation of ready-made expert advisors (EAs) based on classes provided with the client terminal. It enables quick testing of trading ideas by creating custom trading signal classes. The structure and examples for these classes are available in the provided article.Also recommended: trade signals using reversal candlestick patterns in mql5 - similar expert with strong performance on MetaTrader 5.
The core concept involves deriving a trading signal class from a base class, and then overriding virtual methods with custom logic.
A reference book, "Trading Strategies" (in Russian), discusses numerous trading strategies. This guide focuses on reversal candlestick patterns confirmed by RSI and other oscillators.
It is recommended to create a separate class derived from a base pattern class for detecting candlestick patterns. For confirming trade signals generated by these patterns, a class derived from CCandlePattern with added features, such as oscillator confirmation, can be developed.
This guide specifically examines signals based on the "bullish harami" and "bearish harami" reversal candlestick patterns, confirmed by the RSI indicator. The trading signal module utilizes a class that serves as a simple example for creating trade signals with candlestick patterns.
1. Bullish Harami and Bearish Harami Reversal Candlestick Patterns
1.1. Bullish Harami
The bullish harami reversal pattern appears in a downtrend. It consists of a large candlestick followed by a smaller candlestick whose body is contained within the vertical range of the larger body. This pattern suggests a potential reversal of the downtrend, signaling an opportunity for a long position entry. The second candlestick typically opens with a gap up.
The smaller the second (white) candlestick, the higher the probability of a reversal.
Figure 1. "Bullish Harami" Candlestick Pattern
The recognition of the "bullish harami" pattern is implemented in the checkPatternBullishHarami() method of the class.
The checkCandlestickPattern(candle_pattern_bullish_harami) method of the class is used to verify the formation of the "bullish harami" candlestick pattern.
1.2. Bearish Harami
The bearish harami reversal pattern occurs in an uptrend. It is formed by a large candlestick followed by a smaller candlestick whose body is within the vertical range of the larger body. This pattern indicates a possible reversal of the uptrend, suggesting a good time to enter a short position. The second candlestick usually opens with a gap down.
The smaller the second (black) candlestick, the greater the likelihood of reversal.
Figure 2. "Bearish Harami" Candlestick Pattern
The recognition of the "bearish harami" pattern is implemented in the checkPatternBearishHarami() method of the class.
The checkCandlestickPattern(candle_pattern_bearish_harami) method of the class is used to check for the formation of the "bearish harami" candlestick pattern.
2. Trade Signals Confirmed by RSI Indicator
Trading signals for opening long or short positions must be confirmed by the RSI indicator. The RSI value should be below 40 for a long position and above 60 for a short position.
Closing opened positions depends on RSI values. This can occur in two scenarios:
- If RSI reaches the opposite critical level (70 for long positions, 30 for short positions).
- If a reverse signal is not confirmed (when RSI reaches 30 for long positions and 70 for short positions).
Figure 3. "Bullish Harami" Pattern Confirmed by RSI Indicator
int cbh_bh_rsi::longCondition() - checks conditions for opening a long position (returns 80) and closing a short position (returns 40).
int cbh_bh_rsi::shortCondition() - checks conditions for opening a short position (returns 80) and closing a long position (returns 40).
2.1. Open Long Position / Close Short Position
The formation of a "bullish harami" pattern must be confirmed by the RSI indicator: RSI(1) < 40 (the RSI value of the last completed bar must be less than 40).
A short position should be closed if the RSI has crossed upward through the critical levels of 70 or 30.
2.2. Open Short Position / Close Long Position
The formation of a "bearish harami" pattern must be confirmed by the RSI indicator: RSI(1) > 60 (the RSI value of the last completed bar must be greater than 60).
A long position should be closed if the RSI has crossed downward through the critical levels of 70 or 30.
2.3. Creating an Expert Advisor Using the MQL5 Wizard
The cbh_bh_rsi class is not part of the standard library classes. To use it, download the acml_rsi.mqh file (see attachments) and save it to the client_terminal_data\folder\mql5\include\expert\signal\mysignals. Do the same for the acandlepatterns.mqh file. You can then use these files in the MQL5 Wizard after restarting the MetaEditor.
To create an expert advisor, launch the MQL5 Wizard.
Figure 4. Creating an Expert Advisor Using the MQL5 Wizard
Specify the name of the expert advisor.
Figure 5. General Properties of the Expert Advisor
Next, select the trading signal modules to be used.
Figure 6. Signal Properties of the Expert Advisor
In this case, only one trading signal module is used.
Add the "Signals based on Bullish Harami/Bearish Harami Confirmed by RSI" trading signal module.
Figure 7. Signal Properties of the Expert Advisor
The trading signal module is now added.
Figure 8. Signal Properties of the Expert Advisor
You can select any trailing properties; however, we will use "Trailing stop not used".
Figure 9. Trailing Properties of the Expert Advisor
Regarding money management properties, we will use "Trading with fixed trade volume".
Figure 10. Money Management Properties of the Expert Advisor
Pressing the "Finish" button will generate the expert advisor code, named expert_abh_bh_rsi.mq5, which will be saved in the terminal_data_folder\mql5\experts\.
The default input parameters of the generated expert advisor:
Must be replaced with:
The signal_thresholdOpen and signal_thresholdClose input parameters allow specifying threshold levels for opening and closing positions.
In the code of the longCondition() and shortCondition() methods of the trade signals class, fixed threshold values were specified:
- Open position: 80
- Close position: 40
The expert advisor generated by the MQL5 Wizard opens and closes positions using "votes" from the trading signal modules. The vote of the main module (acting as a container for all added modules) is also used. However, its longCondition() and shortCondition() methods always return 0.
The vote results of the main module are also used in "votes" averaging. In this scenario, we have the main module plus one trading signal module. Therefore, this must be considered when setting threshold values. Consequently, thresholdOpen and thresholdClose must be set to 40 = (0+80)/2 and 20 = (0+40)/2, respectively.
The values of signal_stopLevel and signal_takeLevel input parameters are set to 0, indicating that positions will only be closed when the specified closing conditions are met.
2.4. History Backtesting Results
Let's examine the backtesting results of the expert advisor on historical data (EURUSD H1, testing period: 2010.01.01-2011.03.11, RSI period=37, MA period=7).
During the expert advisor creation, fixed volume (0.1) was used, and a trailing stop algorithm was not employed.
Figure 11. Testing Results of the Expert Advisor Based on Bullish Harami/Bearish Harami + RSI
The optimal set of input parameters can be determined using the Strategy Tester in the MetaTrader 5 client terminal.
The code for the expert advisor created by the MQL5 Wizard is attached as expert_aml_rsi.mq5.
You may also like: mql5 wizard: trade signals with dark cloud cover/piercing line and rsi confirmation - excellent alternative for expert users on MetaTrader 5.
Source Code
#property copyright "robotfx"
#property link "https://robotfx.org"
#property version "1.00"
#include <expert\expert.mqh>
#include <expert\signal\mysignals\acbh_bh_rsi.mqh>
#include <expert\trailing\trailingnone.mqh>
#include <expert\money\moneyfixedlot.mqh>
input string expert_title ="expert_abh_bh_rsi"; // document name
ulong expert_magicnumber =31438; //
bool expert_everytick =false; //
.......
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.