MQL5 Wizard: Hammer/Hanging Man Trade Signals with RSI Confirmation
Info
The MQL5 Wizard: Hammer/Hanging Man Trade Signals with RSI Confirmation is a Expert Advisor for MetaTrader 5 that this tool allows the creation of ready-made expert advisors based on classes delivered with the client terminal. It enables quick testing of your trading ideas by creating your own trading signals class.
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: Hammer/Hanging Man Trade Signals with 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 the creation of ready-made Expert Advisors based on classes delivered 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 the creation of ready-made Expert Advisors based on classes delivered with the client terminal. It enables quick testing of your trading ideas by creating your own trading signals class. The structure of this class and an example can be found in the provided resources. The generic idea is to derive a trading signals class from the base class and override the virtual methods with your own logic.Also recommended: trade signals using reversal candlestick patterns in mql5 - similar expert with strong performance on MetaTrader 5.
A book titled "Trading Strategies" (in Russian) discusses numerous trading strategies. This guide focuses on reversal candlestick patterns confirmed by RSI and other oscillators.
The recommended approach is to create a separate class derived from the base pattern class for identifying candlestick patterns. For confirming trade signals generated by these patterns, you can create a class derived from `ccandlepattern` and add necessary features, such as oscillator confirmation.
This guide specifically covers signals based on the "hammer" and "hanging man" reversal candlestick patterns, confirmed by the RSI indicator. The trade signal module is based on the provided class structure, offering a simple example for creating trade signals with candlestick patterns.
1. Hammer and Hanging Man Reversal Candlestick Patterns
1.1. Hammer
The "hammer" is a candlestick pattern with a small body and a long lower wick, typically formed after a downward price movement. It suggests the potential end of a bearish trend.
The color of the candlestick body is not critical, but a bullish hammer indicates a stronger bullish potential. The body of the hammer pattern often forms near the low of the previous candle. A longer lower wick and a shorter upper wick increase the potential of this reversal pattern.
The recognition of the "hammer" pattern is implemented in the `checkpatternhammer()` method.
1.2. Hanging Man
The "hanging man" is a candlestick pattern with a small body and a long lower wick, typically formed after an upward price movement. It suggests the potential end of a bullish trend.
The color of the candlestick body is not critical, but a bearish candle indicates a stronger bearish potential. The body of the "hanging man" pattern often forms near the high of the previous candle. A longer lower wick and a shorter upper wick increase the potential of this reversal pattern.
The recognition of the "hanging man" pattern is implemented in the `checkpatternhangingman()` method.
2. Trade Signals Confirmed by RSI Indicator
Trading signals to open long or short positions must be confirmed by the RSI indicator. The RSI value should be below critical levels (e.g., below 40 for a long position) or above critical levels (e.g., above 60 for a short position).
The closing of opened positions depends on the RSI values. Positions can be closed in two scenarios:
- If RSI has reached the opposite critical level (e.g., 70 for a long position, 30 for a short position).
- If the reverse signal is not confirmed (when RSI reaches specific levels, e.g., 30 for a long position, 70 for a short position).
The `longcondition()` method checks conditions to open a long position or close a short position.
The `shortcondition()` method checks conditions to open a short position or close a long position.
2.1. Open Long Position / Close Short Position
The formation of a "hammer" 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 the critical levels of 70 or 30.
2.2. Open Short Position / Close Long Position
The formation of a "hanging man" 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 the critical levels of 70 or 30.
2.3. Creating an Expert Advisor Using MQL5 Wizard
The `ch_hm_rsi` class is not included in the standard library. To use it, download the `ach_hm_rsi.mqh` file and save it to your `client_terminal_data_folder\mql5\include\expert\signal\mysignals` directory. The same applies to the `candlepatterns.mqh` file. You can then use them in the MQL5 Wizard after restarting MetaEditor.
To create an Expert Advisor, launch the MQL5 Wizard. Specify the name of the Expert Advisor and configure its general properties.
Next, select the trade signal modules. In this case, use only one module: "Signals based on Hammer/Hanging Man confirmed by RSI".
Add the specified module of trading signals.
Configure trailing stop properties; "trailing stop not used" is an option.
For money management properties, "trading with fixed trade volume" can be used.
After pressing the "Finish" button, the generated Expert Advisor code will be located in `expert_ah_hm_rsi.mq5` and saved in `terminal_data_folder\mql5\experts\`.
The default input parameters of the generated Expert Advisor need adjustment. 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 trade signal modules. The vote of the main module (which contains all added modules) is also used, but its `longcondition()` and `shortcondition()` methods always return 0. The vote results of the main module are also used in "votes" averaging. In this case, with a main module plus one trade signal module, the threshold values must be adjusted accordingly. Because of this, `thresholdopen` should be set to 40 ( (0+80)/2 ) and `thresholdclose` to 20 ( (0+40)/2 ).
The values of `signal_stoplevel` and `signal_takelevel` input parameters are set to 0, indicating that positions will be closed only when their specific closing conditions are met.
2.4. History Backtesting Results
Backtesting results on historical data (EURUSD H1, testing period: 2010.01.01-2026.03.03, RSI period=33, MA period=2) are presented. In creating the Expert Advisor, fixed volume (e.g., 0.1) was used, and the trailing stop algorithm was not employed.
The best set of input parameters can be found using the Strategy Tester of MetaTrader 5 client terminal.
The Expert Advisor code, created by the MQL5 Wizard, is attached as `expert_ah_hm_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\ach_hm_rsi.mqh>
#include <expert\trailing\trailingnone.mqh>
#include <expert\money\moneyfixedlot.mqh>
input string expert_title ="expert_ah_hm_rsi"; // document name
ulong expert_magicnumber =15315; //
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.