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

MQL5 Wizard - Trading Signals Based on Alligator Line Crossover - MetaTrader 5 Expert - MT4/MT5 Resources

author EAcpu | 5 reads | 0 comments |

MQL5 Wizard - Trade Signals Based on Crossover of Lines of the Alligator Indicator - expert for MetaTrader 5

MQL5 Wizard - Trade Signals Based on Crossover of Lines of the Alligator Indicator - expert for MetaTrader 5

MQL5 Wizard - Trade Signals Based on Crossover of Lines of the Alligator Indicator - expert for MetaTrader 5

MQL5 Wizard provides automatic creation of Expert Advisors (see MQL5 Wizard: Creating Expert Advisors without Programming ).

Trade signals:

This strategy is implemented in the CSignalAlligator class.

MQL5 Wizard - Trade Signals Based on Crossover of Lines of the Alligator Indicator - expert for MetaTrader 5

Figure 1. Trading signals based on the Alligator technical indicator

The trading strategy is implemented in CSignalAlligator, which has some protected methods to simplify access to indicator values:

 Double Jaws ( Integer Industrial) //Return the value of the bar jawline
Double Teeth ( Integer Industrial) // Return the tooth line value of the bar
Double Lips ( Integer Industrial) // Return the lip line value of the column line
Double Lip Teeth Difference ( Integer Industrial) // Returns the difference between the lip line and the tooth line
Double dental mandibular difference ( Integer Industrial) // Returns the difference between the tooth line and the jaw line
Double lip-chin difference ( integer industrial) // Returns the difference between lip line and jaw line
boolean checkcross(); // Used to check for crosses of alligator lines


1. Open a long position

The examination of the terms of trade has some characteristics due to the movement of the lip line, tooth line and jaw line.

Conditions for opening a long position:

 //+------------------------------------------------------------------+
//|Check the conditions for opening a long position (Buy) |
//+------------------------------------------------------------------+
Boolean CSignalAlligator::CheckOpenLong( double &price, double &SL, double &tp,DateTime&ExpiryDate)
  {
if (checkcross()) returns ( false ); //--- price = 0.0 ;
  SL = 0.0 ;
  tp = 0.0 ; //--- if (Difference between lips and teeth (- 2 )>=Difference between lips and teeth (- 1 ) && Difference between lips and teeth (- 1 )>=Difference between lips and teeth ( 0 ) && Difference between lips and teeth ( 0 )>= 0.0 &&
      TeethJawDiff(- 2 ) >=TeethJawDiff(- 1 ) && TeethJawDiff(- 1 ) >=TeethJawDiff( 0 ) && TeethJawDiff( 0 ) >= 0.0 )
      m_crossed= true ; //--- return (m_crossed);
  }


2. Long position closing

Conditions for closing a position (note the movement of the line):

//+------------------------------------------------------------------+
//|Check closing conditions|
//+------------------------------------------------------------------+
Boolean value CSignalAlligator::CheckCloseLong( double and price)
  {
  Price = 0.0 ; //--- return (lip tooth difference (- 1 ) < 0 && lip tooth difference ( 0 ) >= 0 && lip tooth difference ( 1 ) > 0 );
  }


3. Open a short position

Conditions for opening a short position:

 //+------------------------------------------------------------------+
//|Check the conditions for opening a short position (sell) |
//+------------------------------------------------------------------+
boolean CSignalAlligator::CheckOpenShort( double &price, double &sl, double &tp,datetime&expiryDate)
  {
if (checkcross()) returns ( false ); //--- price = 0.0 ;
  SL = 0.0 ;
  tp = 0.0 ; //--- if (Difference between lips and teeth (- 2 ) <= Difference between lips and teeth (- 1 ) && Difference between lips and teeth (- 1 ) <= Difference between lips and teeth ( 0 ) && Difference between lips and teeth ( 0 ) <= 0.0 &&
      TeethJawDiff(- 2 ) <=TeethJawDiff(- 1 ) && TeethJawDiff(- 1 ) <=TeethJawDiff( 0 ) && TeethJawDiff( 0 ) <= 0.0 )
      m_crossed= true ; //--- return (m_crossed);
  }


4. Close position

Short position closing conditions:

 //+------------------------------------------------------------------+
//|Check short position closing conditions|
//+------------------------------------------------------------------+
Boolean CSignalAlligator::CheckCloseShort( double and price)
  {
  Price = 0.0 ; //--- return (lip and tooth difference (- 1 )> 0 && lip and tooth difference ( 0 ) <= 0 && lip and tooth difference ( 1 ) < 0 );
  }

Create an Expert Advisor using the MQL5 Wizard

To create a trading robot based on a strategy, you need to select the signal property as " Signal based on Alligator lines " in the "Create ready-made Expert Advisor" option in the MQL5 Wizard :

MQL5 Wizard - Trade Signals Based on Crossover of Lines of the Alligator Indicator - expert for MetaTrader 5

Figure 2. Select “Signals based on Alligator lines” in the MQL5 Wizard

Next you must specify the required trailing stop algorithm and money and risk management system. The code of the Expert Advisor will be automatically created and you can compile and test it with the Strategy Tester MetaTrader 5 client terminal.

Test results

Let's consider Expert Advisor's backtest on historical data (EURUSD H1, test period: January 1, 2010 - January 5, 2011, JawPeriod=13, JawShift=8, TeethPeriod=8, TeethShift=5, LipsPeriod=5, LipsShift=3, MaMethod=2, Applied=5, CrossMeasure=5).

When creating the EA, we used a fixed trading volume ( fixed lot size for trading , 0.1) and did not use the trailing stop algorithm ( trailing was not used ).

MQL5 Wizard - Trade Signals Based on Crossover of Lines of the Alligator Indicator - expert for MetaTrader 5

You can increase your profits if you use trade filters based on time and take market characteristics into account. The CSignalITF class will allow you to add a time of day filter. The best time strategy tester MetaTrader 5 client can be found using the following methods. See the example MQL5 Wizard - Trading signals based on two EMA crossovers and intraday time filter .

Attachment: SignalAlligator.mqh with CSignalAlligator class must be placed in terminal_data_folder\MQL5\Include\Expert\Signal folder.

Expert_alligator.mq5 contains the code of the Expert Advisor created using the MQL5 Wizard.


Attachment download

📎 signalalligator.mqh (12.46 KB)

📎 expert_alligator.mq5 (6.81 KB)

Source: MQL5 #267

Verification code Refresh