Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

MQL5 Wizard - Candlestick Patterns + Stochastic Trading Signals - MetaTrader 5 Expert - MT4/MT5 Resources

author EAcpu | 5 reads | 0 comments |

MQL5 Wizard - Trading Signals of Candlestick Patterns + Stochastic - expert for MetaTrader 5

MQL5 Wizard - Trading Signals of Candlestick Patterns + Stochastic - expert for MetaTrader 5

Using "reversal" candlestick patterns in conjunction with oscillatory signals can reduce the number of false signals and increase the efficiency of your trading system.

In this description, we will consider the resulting stochastic indicator signals from the combined use of all these models.

1. Bullish and bearish candlestick models and their detection

The Candlestick Patterns class also has the ability to detect the formation of certain bullish and bearish candlestick patterns (in addition to hammer/hanging man combinations).

The formation of bearish candlestick patterns is checked by the CheckPatternAllBullish() function:

 //+------------------------------------------------------------------+
//|Check the formation of bullish patterns |
//+------------------------------------------------------------------+
Boolean valueCCandlePattern ::CheckPatternAllBullish()
  {
return (CheckPatternThreeWhiteSoldiers() || 
          CheckPatternPiercingLine() || 
          CheckPatternMorningDoji() || 
          CheckPatternBullishEngulfing() || 
          CheckPatternBullishHarami() || 
          CheckPatternMorningStar() || 
          CheckPatternBullishMeetingLines());
  }

The formation of bullish candlestick patterns is checked by the CheckPatternAllBearish() function:

A long/short position is opened when one of the bullish/bearish patterns forms and gets confirmation from a trader. Stochastic Oscillator . The %D signal line values ​​should be above or below the appropriate critical levels (30 and 70).

Exit signals are formed in two situations:

Checking market entry and exit conditions can be done by:

2.1. Open long positions and close short positions

The signal for establishing a long position is the formation of a bullish candlestick combination and the condition StochSignal(1)<30 (the value of the indicator signal line of the random last completed bar is less than 30);

The signal to close short positions is forming one of the bullish candlestick patterns or the case where the indicator line crosses the 20 level Stochastic line (up) or the 80 level line (up).

 //+------------------------------------------------------------------+
//|Method to check whether the market model is formed|
//|Check the conditions of |
//|Enter (short position, m_pattern_0) |
//|Exit (Close position, m_pattern_1) |
//+------------------------------------------------------------------+
IntegerCCP_Stoch ::LongCondition()
  {
integer resolution = 0 ; //---- Check the conditions for opening a short position
//---- Bullish pattern of Stochastic <30 and formation of signal line if (CheckPatternAllBullish() && (StochSignal( 1 )< 30 )) res=m_pattern_0; // Signal to open long position

//--- Check short closing conditions
//--- A bearish pattern is formed or a signal line crosses (up 20, up 80) if (CheckPatternAllBullish() ||
      ((StochSignal( 1 )> 20 ) && (StochSignal( 2 )< 20 )) || 
      ((StochSignal( 1 )> 80 ) && (StochSignal( 2 )< 80 ))) res=m_pattern_1; // Close signal
//--- return (research);
  }

2.2. Open a short position and close a long one

The signal for opening a short position is forming one of the bearish candlestick patterns and fulfilling the condition StochSignal(1)>70 (the indicator signal line of the stochastic last completion bar exceeds 70):

The signal to close long positions is forming one of the bearish candlestick patterns or the case where the indicator line crosses the 80 level stochastic line (downward) or the 20 level line (downward).

To create a trading robot that follows this strategy, go through the MQL5 Wizard and select the signal type in the second step of " Signals based on candlestick patterns + random ":

MQL5 Wizard - Trading Signals of Candlestick Patterns + Stochastic - expert for MetaTrader 5

In subsequent steps, specify the necessary trailing stop type and money management system. The code for the Expert Advisor is automatically generated. Now, it should be compiled and ready to start testing.

2.4.Test results

The results of the EA trading test on historical data (EURUSD H1, test period: 1.1.2000-02.02.2011, PeriodK=33, PeriodD=37, PeriodSlow=30, MA_period=25).

This Expert Advisor uses this module to trade with a fixed trading volume of 0.1 lots ( trading with fixed lots ). No trailing stop is used ( no trailing is used ).

MQL5 Wizard - Trading Signals of Candlestick Patterns + Stochastic - expert for MetaTrader 5

Use MetaTrader 5 to find the best strategy tester for your trading system parameter set.

The EA trading code created by the MQL5 Wizard is attached in the Expert_cp_stoch.mq5 file.


Attachment download

📎 candlepatterns.mqh (24.26 KB)

📎ccp_stoch_m.mqh (9.58 KB)

📎 expert_cp_stoch.mq5 (7.14 KB)

Source: MQL5 #327

Verification code Refresh