The MQL5 Wizard is a powerful tool that enables traders to create ready-to-use Expert Advisors (EAs) based on the Standard Library classes bundled with the MetaTrader 5 terminal. This tool streamlines the process of testing your trading ideas—just whip up your own trading signals class. For a deep dive into creating your own signals, check out the article on MQL5 Wizard: How to Create a Module of Trading Signals.
The basic concept here is simple: derive your trading signals class from the CExpertSignal class. You'll need to override the LongCondition() and ShortCondition() methods with your own logic.
A great resource for strategies is the book "Strategies of Best Traders". Although it’s in Russian, it covers a multitude of trading strategies with a focus on reversal candlestick patterns verified by indicators like the Stochastic, CCI, MFI, and RSI.
The best practice is to create a separate class derived from CExpertSignal to check for the formation of candlestick patterns. To confirm trade signals generated from these patterns, simply write a class derived from CCandlePattern and integrate your confirmation features, such as oscillators.
In this post, we’ll focus on signals based on the "Bullish/Bearish Meeting Lines" reversal candlestick patterns, which are confirmed by the Stochastic indicator. The trade signal module uses the CCandlePattern class, providing a straightforward example of how to create trade signals using candlestick patterns.
1. Understanding "Meeting Lines" Reversal Patterns
1.1. Bullish Meeting Lines
This pattern consists of two candles (bearish followed by bullish) with nearly equal closing prices. The bodies of both candlesticks should be longer than the average body length.
The "Bullish Meeting Lines" pattern signifies a reversal in a downward trend.

Figure 1. Bullish Meeting Lines pattern
The identification of the "Bullish Meeting Lines" pattern is carried out in the CheckPatternBullishMeetingLines() method of the CCandlePattern class:
//+--------------------------------------------------------------------+ //| Checks formation of "Bullish Meeting Lines" candlestick pattern | //+--------------------------------------------------------------------+ bool CCandlePattern::CheckPatternBullishMeetingLines() { //--- Bullish Meeting Lines if((Open(2)-Close(2)>AvgBody(1)) && // long black ((Close(1)-Open(1))>AvgBody(1)) && // long white (MathAbs(Close(1)-Close(2))<0.1*AvgBody(1))) // doji close return(true); //--- return(false); }
The CheckCandlestickPattern(CANDLE_PATTERN_BULLISH_MEETING_LINES) method in the CCandlePattern class is utilized to verify the formation of the "Bullish Meeting Lines" candlestick pattern.
1.2. Bearish Meeting Lines
The pattern consists of two candlesticks (bullish and bearish) with nearly equal closing prices. The bodies should be larger than the average body length.
The "Bearish Meeting Lines" pattern indicates a reversal in an upward trend.

Figure 2. Bearish Meeting Lines pattern
The recognition of the "Bearish Meeting Lines" pattern occurs in the CheckPatternBearishMeetingLines() method of the CCandlePattern class:
//+--------------------------------------------------------------------+ //| Checks formation of "Bearish Meeting Lines" candlestick pattern | //+--------------------------------------------------------------------+ bool CCandlePattern::CheckPatternBearishMeetingLines() { //--- Bearish Meeting Lines if((Close(2)-Open(2)>AvgBody(1)) && // long white ((Open(1)-Close(1))>AvgBody(1)) && // long black (MathAbs(Close(1)-Close(2))<0.1*AvgBody(1))) // doji close return(true); //--- return(false); }
The CheckCandlestickPattern(CANDLE_PATTERN_BEARISH_MEETING_LINES) method in the CCandlePattern class checks for the formation of the "Bearish Meeting Lines" pattern.
2. Trade Signals Confirmed by the Stochastic Indicator
To open long or short positions, the trade signals must be verified by the Stochastic oscillator. The %D line should be above or below the critical levels (30 for buy, 70 for sell).
Closing an open position depends on the %D indicator values. There are two scenarios:
- When the %D line hits the opposite critical level (80 for long positions and 20 for short positions)
- When the reverse signal isn't confirmed (if %D reaches 20 for long positions and 80 for short positions)

Fig. 3. Bearish Meeting Lines pattern, confirmed by Stochastic indicator
- int CML_Stoch::LongCondition() - checks conditions to open a long position (returns 80) and close the short position (returns 40);
- int CML_Stoch::ShortCondition() - checks conditions to open a short position (returns 80) and close the long position (returns 40).
2.1. Opening Long Position / Closing Short Position
The formation of the "Bullish Meeting Lines" pattern must be validated by the Stochastic indicator: StochSignal(1)<30 (the last completed bar's signal line should be below 30).
Close the short position if the Stochastic signal line crosses above the 20 or 80 levels.
//+------------------------------------------------------------------+ //| Checks conditions for entry and exit from market | //| 1) Market entry (open long position, result=80) | //| 2) Market exit (close short position, result=40) | //+------------------------------------------------------------------+ int CML_Stoch::LongCondition() { int result=0; //--- idx can be used to determine Expert Advisor work mode //--- idx=0 - in this case EA checks trade conditions at each tick //--- idx=1 - in this case EA checks trade conditions only at news bars int idx =StartIndex(); //--- checking of conditions to open long position //--- formation of Bullish Meeting Lines pattern and signal line<30 if (CheckCandlestickPattern(CANDLE_PATTERN_BULLISH_MEETING_LINES) && (StochSignal(1)<30)) result=80; //--- checking of conditions to close short position //--- signal line crossover of overbought/oversold levels (downward 20, upward 80) if((((StochSignal(1)>20) && (StochSignal(2)<20)) || ((StochSignal(1)>80) && (StochSignal(2)<80)))) result=40; //--- return result return(result); }
2.2. Opening Short Position / Closing Long Position
The formation of the "Bearish Meeting Lines" pattern must be confirmed by the Stochastic indicator: StochSignal(1)>70 (the last completed bar's signal line should be above 70).
The long position should be closed if the Stochastic signal line crosses below the 80 or 20 levels.
//+------------------------------------------------------------------+ //| Checks conditions for entry and exit from market | //| 1) Market entry (open short position, result=80) | //| 2) Market exit (close long position, result=40) | //+------------------------------------------------------------------+ int CML_Stoch::ShortCondition() { int result=0; //--- idx can be used to determine Expert Advisor work mode //--- idx=0 - in this case EA checks trade conditions at each tick //--- idx=1 - in this case EA checks trade conditions only at news bars int idx =StartIndex(); //--- checking of conditions to open short position //--- formation of Bearish Meeting Lines pattern and signal line>70 if (CheckCandlestickPattern(CANDLE_PATTERN_BEARISH_MEETING_LINES) && (StochSignal(1)>70)) result=80; //--- checking of conditions to close long position //--- signal line crossover of overbought/oversold levels (downward 80, upward 20) if((((StochSignal(1)<80) && (StochSignal(2)>80)) || ((StochSignal(1)<20) && (StochSignal(2)>20)))) result=40; //--- return result return(result); }
2.3. Creating an Expert Advisor with MQL5 Wizard
The CML_Stoch class is not part of the Standard Library, so you'll need to download the acml_stoch.mqh file (linked in the attachments) and save it to your client terminal's data folder under MQL5\Include\Expert\Signal\MySignals. The same goes for the candlepatterns.mqh file. Once you've done this, restart the MetaEditor to use them in MQL5 Wizard.
To create your Expert Advisor, launch the MQL5 Wizard:

Fig. 4. Creating Expert Advisor using MQL5 Wizard
Next, specify the name of your Expert Advisor:

Fig. 5. General properties of the Expert Advisor
Then, select the trade signal modules to be used.

Fig. 6. Signal properties of the Expert Advisor
In this case, we only utilize one trade signal module.
Adding the "Signals Based on Bullish/Bearish Meeting Lines Confirmed by Stochastic" module of trading signals:

Fig. 7. Signal properties of the Expert Advisor
The trade signal module has been added:

Fig. 8. Signal properties of the Expert Advisor
You can select any trailing properties, but we’ll opt for "No Trailing Stop":

Fig. 9. Trailing properties of the Expert Advisor
For money management, we’ll use "Trading with Fixed Trade Volume":

Fig. 10. Money management properties of the Expert Advisor
By clicking the "Finish" button, you’ll receive the code for the generated Expert Advisor, saved as Expert_AML_Stoch.mq5 in terminal_data_folder\MQL5\Experts\.
The default input parameters for the generated Expert Advisor are as follows:
//--- inputs for main signal input int Signal_ThresholdOpen =10; // Signal threshold value to open [0...100] input int Signal_ThresholdClose =10 // Signal threshold value to close [0...100] input double Signal_PriceLevel =0.0 // Price level to execute a deal input double Signal_StopLevel =50.0 // Stop Loss level (in points) input double Signal_TakeLevel =50.0 // Take Profit level (in points)
These parameters should be replaced with the following:
//--- inputs for main signal input int Signal_ThresholdOpen =40; // Signal threshold value to open [0...100] input int Signal_ThresholdClose =20 // Signal threshold value to close [0...100] input double Signal_PriceLevel =0.0 // Price level to execute a deal input double Signal_StopLevel =0.0 // Stop Loss level (in points) input double Signal_TakeLevel =0.0 // Take Profit level (in points)
The Signal_ThresholdOpen and Signal_ThresholdClose input parameters allow you to set threshold levels for opening and closing positions.
In the LongCondition() and ShortCondition() methods of the trade signals class, we specified the following fixed threshold values:
- Open position: 80;
- Close position: 40.
The Expert Advisor generated by the MQL5 Wizard opens and closes positions based on the "votes" from the signal modules. The main module's vote is also utilized in the average voting process, but its LongCondition() and ShortCondition() methods always return 0.
In our case, we have one main module plus one signal module, which means we need to adjust the threshold values accordingly. This leads us to set ThresholdOpen to 40 (the average of 0 and 80) and ThresholdClose to 20 (the average of 0 and 40).
Setting the Signal_StopLevel and Signal_TakeLevel input parameters to 0 means that positions will only be closed when the closing conditions are satisfied.
2.4. Backtesting Results
Now, let’s review the backtesting results for our Expert Advisor using historical data (EURUSD H1, testing period: 2005.01.01-2010.03.16, PeriodK=6, PeriodD=3, PeriodSlow=36, MA_period=3).
In creating the Expert Advisor, we used a fixed volume (Trading Fixed Lot, 0.1), and the Trailing Stop algorithm was not employed (Trailing not used).

Fig. 11. Testing results of the Expert Advisor, based on Bullish/Bearish Meeting Lines + Stochastic
The best input parameters can be identified by using the Strategy Tester in the MetaTrader 5 terminal.
The code for the Expert Advisor created by the MQL5 Wizard is attached in expert_aml_stoch.mq5.
Related Posts
- Mastering Trading Signals with MQL5 Wizard: Bullish and Bearish Engulfing Strategies
- Harnessing MQL5 Wizard for Trading Signals: 3 Black Crows & 3 White Soldiers with MFI
- Creating a Stochastic-Based EA for Hammer and Hanging Man Patterns in MetaTrader 5
- RRS Impulse: Your Go-To Scalping EA for MetaTrader 4
- Creating Powerful Trade Signals with MQL5 Wizard: Bullish and Bearish Engulfing Patterns + RSI