Trade Signals: Morning/Evening Stars with MFI Confirmation using MQL5 Wizard
Info
The Trade Signals: Morning/Evening Stars with MFI Confirmation using MQL5 Wizard 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 facilitates quick testing of your trading ideas by enabling you to create your own 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 Trade Signals: Morning/Evening Stars with MFI Confirmation 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 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: Quantora Trade Manager MT5: Advanced Position Management - 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 facilitates quick testing of your trading ideas by enabling you to create your own trading signal classes. The structure and an example of such a class can be found in the linked article.Also recommended: Professional Automatic Trailing Stop Utility for MetaTrader 5 - similar expert with strong performance on MetaTrader 5.
The general concept involves deriving a trading signal class from a base class and then overriding specific virtual methods with your custom logic.
A resource titled "Trading Strategies" (in Russian) details numerous trading strategies. This guide focuses on reversal candlestick patterns, specifically confirmed by the MFI indicator and oscillators.
For optimal organization, it is recommended to create a separate class derived from the base class for identifying candlestick patterns. To confirm trade signals generated by these patterns, you can extend the base class by adding necessary features, such as confirmation by oscillators.
This guide specifically examines signals based on the "Morning Star/Evening Star" (including "Morning Doji Star/Evening Doji Star") reversal candlestick patterns, confirmed by the MFI indicator. The trading signal module is built upon a base class, and a simple example demonstrates its use for creating candlestick pattern-based trade signals.
Morning Star and Evening Star Reversal Candlestick Patterns
Morning Star
This pattern signifies a downtrend reversal and consists of three candles. Following a long bearish (black) candle, a candle with a small body appears, whose body is contained within the body of the preceding black candle. This small body suggests market equilibrium between bulls and bears, indicating a potential trend change.
The third candle in the pattern is a bullish (white) candle. Its body does not overlap with the second candle's body, and its closing price falls within the body of the first (bearish) candle. Figure 1 illustrates this pattern.
When the second candle is a doji, the pattern is referred to as a "Morning Doji Star."
Figure 1. "Morning Star" and "Morning Doji Star" Candlestick Patterns
The identification of "Morning Star" and "Morning Doji Star" patterns is implemented in the checkpatternmorningstar() and checkpatternmorningdoji() methods, respectively. The CheckCandlestickPattern() methods of the relevant classes are used to verify the formation of these patterns.
Evening Star
This pattern indicates an uptrend reversal and also comprises three candles. Preceding a long bullish (white) candle, a candle with a small body emerges, which is contained within the body of the preceding white candle. This suggests a balance of power between bulls and bears, pointing to a potential trend reversal.
The third candle is a bearish (black) candle. Its body does not overlap with the second candle's body, and its closing price is within the body of the first (bullish) candle. Figure 2 illustrates this pattern.
If the second candle is a doji, the pattern is called an "Evening Doji Star."
Figure 2. "Evening Star" and "Evening Doji Star" Candlestick Patterns
The methods for identifying "Evening Star" and "Evening Doji Star" patterns are provided. The CheckCandlestickPattern() methods are utilized to confirm the formation of these patterns.
Trade Signals Confirmed by MFI Indicator
Trading signals for opening long or short positions must be validated by the MFI indicator. For long positions, the MFI value should be below 40, and for short positions, it should be above 60.
The closing of open positions is triggered in two scenarios:
- The MFI has reached the opposing critical level (70 for long positions, 30 for short positions).
- A reverse signal is not confirmed (when the MFI indicator reaches specific levels: 30 for long positions, 70 for short positions).
Figure 3. The "Morning Star" Pattern Confirmed by MFI Indicator
The cms_es_mfi::longcondition() method checks conditions for opening a long position (returns 80) and closing a short position (returns 40).
The cms_es_mfi::shortcondition() method checks conditions for opening a short position (returns 80) and closing a long position (returns 40).
Opening Long Position / Closing Short Position
The formation of a "Morning Star" 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 upward past the critical levels (70 or 30).
Opening Short Position / Closing Long Position
The formation of an "Evening Star" 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 upward past the critical levels (70 or 30).
Creating an Expert Advisor Using the MQL5 Wizard
The cms_es_mfi class is not part of the standard library. To use it, download the ams_es_mfi.mqh file (see attachments) and save it to the client_terminal_data_folder\mql5\include\expert\signal\mysignals. Similarly, save the acandlepatterns.mqh file to the same directory. After restarting MetaEditor, you can use these files in the MQL5 Wizard.
To create an Expert Advisor, launch the MQL5 Wizard.
Figure 4. Creating an Expert Advisor Using 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 utilized.
Add the "Signals based on Morning Star/Evening Star confirmed by MFI" trading signal module.
Figure 7. Signal Properties of the Expert Advisor
The trading signal module is added.
Figure 8. Signal Properties of the Expert Advisor
You can select any trailing stop properties; however, "Trailing stop not used" will be used here.
Figure 9. Trailing Properties of the Expert Advisor
Regarding money management, "Trading with fixed trade volume" will be employed.
Figure 10. Money Management Properties of the Expert Advisor
Clicking the "Finish" button will generate the Expert Advisor code, named expert_ams_es_mfi.mq5, which will be saved 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 you to set threshold levels for opening and closing positions.
In the code of the longcondition() and shortcondition() methods of the trading 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 based on "votes" from the trading signal modules. The vote from the main module (which acts 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 incorporated into the "votes" averaging. In this scenario, with the main module plus one trading signal module, the threshold values must be adjusted accordingly. Therefore, thresholdopen and thresholdclose should be set to 40 = (0+80)/2 and 20 = (0+40)/2, respectively.
The signal_stoplevel and signal_takelevel input parameters are set to 0, indicating that positions will be closed solely when the closing conditions are met.
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.16, periodMFI=49, MA_period=3).
During the Expert Advisor creation, a fixed volume (0.1) was used, and the trailing stop algorithm was not enabled.
Figure 11. Testing Results of the Expert Advisor Based on Morning/Evening Stars + MFI
The optimal set of input parameters can be identified using the Strategy Tester within the MetaTrader 5 client terminal.
The code for the Expert Advisor created by the MQL5 Wizard is attached as expert_ams_es_mfi.mq5.
You may also like: Quantora Risk Calculator MT5 - Professional Trade Risk and Reward Calculator - 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\acms_es_mfi.mqh>
#include <expert\trailing\trailingnone.mqh>
#include <expert\money\moneyfixedlot.mqh>
input string expert_title ="expert_ams_es_mfi"; // document name
ulong expert_magicnumber =21726; //
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.