Trade Signals Based on Bullish/Bearish Harami Candlestick Patterns Confirmed by MFI Indicator using MQL5 Wizard

Trade Signals Based on Bullish/Bearish Harami Candlestick Patterns Confirmed by MFI Indicator using MQL5 Wizard
Download ALL MT5 experts (1569)
YouTube Video Thumbnail



Similar MetaTrader Tools

Trade Signals Based on Bullish/Bearish Harami Candlestick Patterns Confirmed by MFI Indicator using MQL5 Wizard

Info

The Trade Signals Based on Bullish/Bearish Harami Candlestick Patterns Confirmed by MFI Indicator using MQL5 Wizard is a Expert Advisor for MetaTrader 5 that this tool allows the creation of ready-made expert advisors (eas) based on classes delivered with the client terminal. It enables quick testing of trading ideas by creating a custom 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 Trade Signals Based on Bullish/Bearish Harami Candlestick Patterns Confirmed by MFI Indicator using MQL5 Wizard

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 (EAs) 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: T5Copier - MT 5 client to client Local trade copier - another powerful expert for MetaTrader 5 traders.

This tool allows the creation of ready-made Expert Advisors (EAs) based on classes delivered with the client terminal. It enables quick testing of trading ideas by creating a custom trading signals class. The structure and an example of this class are provided.

Also recommended: V1N1 LONNY MT5: Asian Range Breakout Day Trader - similar expert with strong performance on MetaTrader 5.


The core concept involves deriving a trading signals class from a base class and overriding specific virtual methods to implement custom trading logic.

A resource titled "" (in Russian) discusses various trading strategies, and this analysis focuses on reversal candlestick patterns confirmed by the MFI indicator and oscillators.

It is recommended to create a separate class derived from the base class for recognizing candlestick patterns. For confirming trade signals generated by these patterns, a class derived from ccandlepattern can be used, incorporating additional features like oscillator confirmation.

This guide focuses on signals derived from the "bullish harami/bearish harami" reversal candlestick pattern, confirmed by the MFI indicator. The trade signals module is based on a specific class, providing a simple example for creating trade signals using 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 a possible entry into a long position. The second candlestick typically opens with an upward gap.
A smaller second (white) candlestick increases the likelihood of a reversal.
Fig. 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 check for the formation of the "bullish harami" candlestick pattern.

1.2. Bearish Harami
The bearish harami reversal pattern occurs in an uptrend. It is characterized by a large candlestick followed by a smaller candlestick whose body is within the vertical range of the larger body. This pattern indicates a potential reversal of the uptrend, signaling a good time to enter a short position. The second candlestick typically opens with a downward gap.
A smaller second (black) candlestick increases the likelihood of a reversal.
Fig. 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 MFI Indicator
Trading signals for opening long or short positions must be confirmed by the MFI indicator. For long positions, the MFI value should be below 40, and for short positions, it should be above 60.
Position closure is determined by MFI indicator values and can occur in two scenarios:

When the MFI reaches the opposite critical level (70 for long positions, 30 for short positions).

When a reverse signal is not confirmed (MFI reaches 30 for long positions, 70 for short positions).
Fig. 3. "Bullish Harami" Pattern Confirmed by MFI Indicator

int cbh_bh_mfi::longcondition() - checks conditions to open a long position (returns 80) and close a short position (returns 40).

int cbh_bh_mfi::shortcondition() - checks conditions to open a short position (returns 80) and close 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 MFI indicator: MFI(1) < 40 (the MFI value of the last completed bar must be less than 40).

A short position should be closed if the indicator has crossed upwards through the critical levels (70 or 30).

2.2. Open Short Position / Close Long Position

The formation of a "bearish harami" pattern must be confirmed by the MFI indicator: MFI(1) > 60 (the MFI value of the last completed bar must be greater than 60).

A long position should be closed if the indicator has crossed upwards through the critical levels (70 or 30).


2.3. Creating an Expert Advisor Using MQL5 Wizard
The cbh_bh_mfi class is not part of the standard library. To use it, download the abh_bh_mfi.mqh file (see attachments) and save it to the client_terminal_data_folder\mql5\include\expert\signal\mysignals directory. The same applies to the acandlepatterns.mqh file. These can be used in the MQL5 wizard after restarting the MetaEditor.

To create an Expert Advisor, launch the MQL5 wizard.
Fig. 4. Creating Expert Advisor Using MQL5 Wizard
Specify the name of the Expert Advisor.
Fig. 5. General Properties of the Expert Advisor
Next, select the trading signal modules to be used.
Fig. 6. Signal Properties of the Expert Advisor
In this case, only one trading signal module is used.
Adding the "Signals based on Bullish Harami / Bearish Harami Confirmed by MFI" module of trading signals:
Fig. 7. Signal Properties of the Expert Advisor
Trading signal module added:
Fig. 8. Signal Properties of the Expert Advisor
Trailing properties can be selected as desired; however, "Trailing stop not used" will be used here.
Fig. 9. Trailing Properties of the Expert Advisor
Regarding money management properties, "Trading with fixed trade volume" will be utilized.
Fig. 10. Money Management Properties of the Expert Advisor
Clicking the "Finish" button generates the Expert Advisor code, saved as expert_abh_bh_mfi.mq5 in the terminal_data_folder\mql5\experts\ directory.

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 are set:

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 main module's vote (as a container for all added modules) is also used, but its longcondition() and shortcondition() methods always return 0.

The main module's vote results are incorporated into "votes" averaging. In this scenario, with the main module plus one trade signal module, the thresholdopen and thresholdclose values must be adjusted accordingly: thresholdopen set to 40 = (0+80)/2, and thresholdclose set to 20 = (0+40)/2.

The values for signal_stoplevel and signal_takelevel input parameters are set to 0, indicating that position closing will only occur when the defined closing conditions are met.


2.4. History Backtesting Results
Backtesting of the Expert Advisor on historical data (EURUSD H1, testing period: 2010.01.01-2011.03.16, periodMFI=37, MA_period=11) is presented.

During Expert Advisor creation, a fixed volume (0.1) was used, and the trailing stop algorithm was not employed.

Fig. 11. Testing Results of the Expert Advisor Based on Bullish Harami / Bearish Harami + MFI

The optimal set of input parameters can be discovered using the Strategy Tester feature within the MetaTrader 5 client terminal.

The code for the Expert Advisor generated by the MQL5 wizard is attached as expert_abh_bh_mfi.mq5.

You may also like: ks q command center: remote trade management for metatrader 5 - 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_mfi.mqh>
#include <expert\trailing\trailingnone.mqh>
#include <expert\money\moneyfixedlot.mqh>
input string expert_title         ="expert_abh_bh_mfi"; // document name
ulong        expert_magicnumber   =8345;                // 
bool         expert_everytick     =false;               // 

.......

Leave your opinion, ask a question, share some knowledge

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.
© ROBOTFX Free educational tools by RobotFX. Use entirely at your own risk; we are not liable for any financial losses incurred.