head and shoulders ea

 
hello everybody i want to build an head and shoulders ea but i dont know where to start ...
 
Right in the too there is a search button, or usemgoogle
 
Ofir Nissim:
hello everybody i want to build an head and shoulders ea but i dont know where to start ...
Free download of the 'Head and Shoulders' expert by 'aharontzadik1' for MetaTrader 4 in the MQL5 Code Base, 2019.07.13
Head and Shoulders
Head and Shoulders
  • www.mql5.com
"Head and Shoulders" naked trading price action EA draws 2 mini Trend Lines with "Fractals" on chart and trades with "Head and Shoulders" strategy,has Trailing Stop Loss &Take Profit works with all time frames major forex pairs and stocks NASDAQ.
 
//+------------------------------------------------------------------+
//|                                                      SmartON.mq4 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
input double TakeProfit    =400;
input double StopLoss      =170; 
input double Lots          =0.75;

void OnTick()
  {
  
int    ticket,total;
  
double spread = Ask - Bid * _Point;

double h1 = iHigh(_Symbol,PERIOD_M5,2);
double h2 = iHigh(_Symbol,PERIOD_M5,3);
double h3 = iHigh(_Symbol,PERIOD_M5,4);
double h4 = iHigh(_Symbol,PERIOD_M5,5);
double h5 = iHigh(_Symbol,PERIOD_M5,6);
double h6 = iHigh(_Symbol,PERIOD_M5,7);
double h7 = iHigh(_Symbol,PERIOD_M5,8);
double h8 = iHigh(_Symbol,PERIOD_M5,9);
double h9 = iHigh(_Symbol,PERIOD_M5,10);
double h10 = iHigh(_Symbol,PERIOD_M5,11);
double h11 = iHigh(_Symbol,PERIOD_M5,12);
double h12 = iHigh(_Symbol,PERIOD_M5,13);
double h13 = iHigh(_Symbol,PERIOD_M5,14);
double h14 = iHigh(_Symbol,PERIOD_M5,15);
double h15 = iHigh(_Symbol,PERIOD_M5,16);
double h16 = iHigh(_Symbol,PERIOD_M5,17);
double h17 = iHigh(_Symbol,PERIOD_M5,18);
double h18 = iHigh(_Symbol,PERIOD_M5,19);

double u1= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,2);
double u2= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,3);
double u3= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,4); 
double u4= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,5);
double u5= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,6);
double u6= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,7);
double u7= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,8);
double u8= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,9);
double u9= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,10);
double u10 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,11);
double u11 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,12);
double u12 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,13);
double u13 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,14);
double u14 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,15);
double u15 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,16);
double u16 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,17);
double u17 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,18);
double u18 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,19);
  
double l1 = iLow(_Symbol,PERIOD_M5,2);  
double l2 = iLow(_Symbol,PERIOD_M5,3);
double l3 = iLow(_Symbol,PERIOD_M5,4);
double l4 = iLow(_Symbol,PERIOD_M5,5);
double l5 = iLow(_Symbol,PERIOD_M5,6);
double l6 = iLow(_Symbol,PERIOD_M5,7);
double l7 = iLow(_Symbol,PERIOD_M5,8);
double l8 = iLow(_Symbol,PERIOD_M5,9);
double l9 = iLow(_Symbol,PERIOD_M5,10);
double l10 = iLow(_Symbol,PERIOD_M5,11);
double l11 = iLow(_Symbol,PERIOD_M5,12);
double l12 = iLow(_Symbol,PERIOD_M5,13);
double l13 = iLow(_Symbol,PERIOD_M5,14);
double l14 = iLow(_Symbol,PERIOD_M5,15);
double l15 = iLow(_Symbol,PERIOD_M5,16);
double l16 = iLow(_Symbol,PERIOD_M5,17);
double l17 = iLow(_Symbol,PERIOD_M5,18);
double l18 = iLow(_Symbol,PERIOD_M5,19);

double d1= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,2);
double d2= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,3);
double d3= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,4); 
double d4= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,5);
double d5= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,6);
double d6= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,7);
double d7= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,8);
double d8= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,9);
double d9= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,10);
double d10 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,11);
double d11 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,12);
double d12 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,13);
double d13 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,14);
double d14 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,15);
double d15 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,16);
double d16 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,17);
double d17 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,18);
double d18 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,19);

bool fair = false;   
Comment("u1",u1,"u5",u5,"u12",u12);
   total=OrdersTotal();
   if(total<1)
     {
      //--- no opened orders identified
      if(AccountFreeMargin()<(1000*Lots))
        {
         Print("We have no money. Free Margin = ",AccountFreeMargin());
         return;
        }
      //--- check for long position (BUY) possibility
      if( 
      l1 > 1 && l5 > 1 && l12 > 1
      ||l1 > 1 && l6 > 1 && l12 > 1
      ||l1 > 1 && l7 > 1 && l12 > 1
      ||l1 > 1 && l8 > 1 && l12 > 1
      ||l1 > 1 && l6 > 1 && l13 > 1
      ||l1 > 1 && l6 > 1 && l14 > 1
      ||l1 > 1 && l6 > 1 && l15 > 1
      ||l1 > 1 && l6 > 1 && l16 > 1
      ||l1 > 1 && l6 > 1 && l17 > 1
      ||l1 > 1 && l6 > 1 && l18 > 1
      ||l1 > 1 && l7 > 1 && l13 > 1
      ||l1 > 1 && l7 > 1 && l14 > 1
      ||l1 > 1 && l7 > 1 && l15 > 1
      ||l1 > 1 && l7 > 1 && l16 > 1
      ||l1 > 1 && l7 > 1 && l17 > 1
      ||l1 > 1 && l7 > 1 && l18 > 1
      ||l1 > 1 && l8 > 1 && l13 > 1
      ||l1 > 1 && l8 > 1 && l14 > 1
      ||l1 > 1 && l8 > 1 && l15 > 1
      ||l1 > 1 && l8 > 1 && l16 > 1
      ||l1 > 1 && l8 > 1 && l17 > 1
      ||l1 > 1 && l8 > 1 && l18 > 1  
       )//
        {
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"macd sample",16384,0,Green);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
               Print("BUY order opened : ",OrderOpenPrice());
           }
         else
            Print("Error opening BUY order : ",GetLastError());
         return;
        }
      //--- check for short position (SELL) possibility
      if(
      u1 > 1 && u5 > 1 && u12 > 1
      ||u1 > 1 && u6 > 1 && u12 > 1
      ||u1 > 1 && u7 > 1 && u12 > 1
      ||u1 > 1 && u8 > 1 && u12 > 1
      ||u1 > 1 && u6 > 1 && u13 > 1
      ||u1 > 1 && u6 > 1 && u14 > 1
      ||u1 > 1 && u6 > 1 && u15 > 1
      ||u1 > 1 && u6 > 1 && u16 > 1
      ||u1 > 1 && u6 > 1 && u17 > 1
      ||u1 > 1 && u6 > 1 && u18 > 1
      ||u1 > 1 && u7 > 1 && u13 > 1
      ||u1 > 1 && u7 > 1 && u14 > 1
      ||u1 > 1 && u7 > 1 && u15 > 1
      ||u1 > 1 && u7 > 1 && u16 > 1
      ||u1 > 1 && u7 > 1 && u17 > 1
      ||u1 > 1 && u7 > 1 && u18 > 1
      ||u1 > 1 && u8 > 1 && u13 > 1
      ||u1 > 1 && u8 > 1 && u14 > 1
      ||u1 > 1 && u8 > 1 && u15 > 1
      ||u1 > 1 && u8 > 1 && u16 > 1
      ||u1 > 1 && u8 > 1 && u17 > 1
      ||u1 > 1 && u8 > 1 && u18 > 1
       )// 
        {
         ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+StopLoss*Point,Bid-TakeProfit*Point,"macd sample",16384,0,Red);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
               Print("SELL order opened : ",OrderOpenPrice());
           }
         else
            Print("Error opening SELL order : ",GetLastError());
        }
      //--- exit from the "no opened orders" block
      return;
     }
  }
//+------------------------------------------------------------------+







//


this is the code i wrote so far i get an error for the || i use to sort buy and sell on top of that it keeps on opening positions regardless to the statments i gave in the if mybe the || warning i get is the problem can someone help ?? thanks


Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 
check operator precedence for possible error; use parentheses to clarify precedence SmartON.mq4 176 16

 

this is the warninng that i get

 
Ofir Nissim #:
check operator precedence for possible error; use parentheses to clarify precedence SmartON.mq4 176 16

 

this is the warninng that i get

You need to put parantesis after every || …. Like…. 
      || ( l1 > 1 && l7 > 1 && l14 > 1 )
 
 Daniel Cioca #:
You need to put parantesis after every || …. Like…. 

Thanks !

 
//+------------------------------------------------------------------+
//|                                                      SmartON.mq4 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
input double TakeProfit    =400;
input double StopLoss      =170; 
input double Lots          =0.75;

void OnTick()
  {
  
int    ticket,total;
  
double spread = Ask - Bid * _Point;

double h1 = iHigh(_Symbol,PERIOD_M5,2);
double h2 = iHigh(_Symbol,PERIOD_M5,3);
double h3 = iHigh(_Symbol,PERIOD_M5,4);
double h4 = iHigh(_Symbol,PERIOD_M5,5);
double h5 = iHigh(_Symbol,PERIOD_M5,6);
double h6 = iHigh(_Symbol,PERIOD_M5,7);
double h7 = iHigh(_Symbol,PERIOD_M5,8);
double h8 = iHigh(_Symbol,PERIOD_M5,9);
double h9 = iHigh(_Symbol,PERIOD_M5,10);
double h10 = iHigh(_Symbol,PERIOD_M5,11);
double h11 = iHigh(_Symbol,PERIOD_M5,12);
double h12 = iHigh(_Symbol,PERIOD_M5,13);
double h13 = iHigh(_Symbol,PERIOD_M5,14);
double h14 = iHigh(_Symbol,PERIOD_M5,15);
double h15 = iHigh(_Symbol,PERIOD_M5,16);
double h16 = iHigh(_Symbol,PERIOD_M5,17);
double h17 = iHigh(_Symbol,PERIOD_M5,18);
double h18 = iHigh(_Symbol,PERIOD_M5,19);
double h19 = iHigh(_Symbol,PERIOD_M5,20);
double h20 = iHigh(_Symbol,PERIOD_M5,21);
double h21 = iHigh(_Symbol,PERIOD_M5,22);

double u1= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,2);
double u2= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,3);
double u3= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,4); 
double u4= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,5);
double u5= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,6);
double u6= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,7);
double u7= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,8);
double u8= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,9);
double u9= iFractals(_Symbol,PERIOD_M5,MODE_UPPER,10);
double u10 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,11);
double u11 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,12);
double u12 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,13);
double u13 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,14);
double u14 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,15);
double u15 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,16);
double u16 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,17);
double u17 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,18);
double u18 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,19);
double u19 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,20);
double u20 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,21);
double u21 =iFractals(_Symbol,PERIOD_M5,MODE_UPPER,22);
  
double l1 = iLow(_Symbol,PERIOD_M5,2);  
double l2 = iLow(_Symbol,PERIOD_M5,3);
double l3 = iLow(_Symbol,PERIOD_M5,4);
double l4 = iLow(_Symbol,PERIOD_M5,5);
double l5 = iLow(_Symbol,PERIOD_M5,6);
double l6 = iLow(_Symbol,PERIOD_M5,7);
double l7 = iLow(_Symbol,PERIOD_M5,8);
double l8 = iLow(_Symbol,PERIOD_M5,9);
double l9 = iLow(_Symbol,PERIOD_M5,10);
double l10 = iLow(_Symbol,PERIOD_M5,11);
double l11 = iLow(_Symbol,PERIOD_M5,12);
double l12 = iLow(_Symbol,PERIOD_M5,13);
double l13 = iLow(_Symbol,PERIOD_M5,14);
double l14 = iLow(_Symbol,PERIOD_M5,15);
double l15 = iLow(_Symbol,PERIOD_M5,16);
double l16 = iLow(_Symbol,PERIOD_M5,17);
double l17 = iLow(_Symbol,PERIOD_M5,18);
double l18 = iLow(_Symbol,PERIOD_M5,19);
double l19 = iLow(_Symbol,PERIOD_M5,20);
double l20 = iLow(_Symbol,PERIOD_M5,21);
double l21 = iLow(_Symbol,PERIOD_M5,22);

double d1= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,2);
double d2= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,3);
double d3= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,4); 
double d4= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,5);
double d5= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,6);
double d6= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,7);
double d7= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,8);
double d8= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,9);
double d9= iFractals(_Symbol,PERIOD_M5,MODE_LOWER,10);
double d10 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,11);
double d11 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,12);
double d12 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,13);
double d13 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,14);
double d14 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,15);
double d15 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,16);
double d16 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,17);
double d17 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,18);
double d18 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,19);
double d19 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,20);
double d20 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,21);
double d21 =iFractals(_Symbol,PERIOD_M5,MODE_LOWER,22);

double Icc = iCCI( 
          NULL,           // symbol 
             PERIOD_H1,        // timeframe 
             14,           // averaging period 
             PRICE_CLOSE,    // applied price 
             0            // shift 
   );

double ma20m5 = iMA( 
   NULL,           // symbol 
          5,        // timeframe 
          20,        // MA averaging period 
          0,         // MA shift 
             0,        // averaging method 
             0,    // applied price 
             0             // shift 
   );

 

double stoc1h = iStochastic( 
          _Symbol,           // symbol 
             PERIOD_H1,        // timeframe 
             5,          // K line period 
             3,          // D line period 
             3,          // slowing 
             MODE_SMA,           // averaging method 
             0,      // price (Low/High or Close/Close) 
             MODE_SIGNAL,             // line index 
             0             // shift 
   );
   
double stoc1m = iStochastic( 
          _Symbol,           // symbol 
             PERIOD_M1,        // timeframe 
             5,          // K line period 
             3,          // D line period 
             3,          // slowing 
             MODE_SMA,           // averaging method 
             0,      // price (Low/High or Close/Close) 
             MODE_SIGNAL,             // line index 
             0             // shift 
   );   
double stoc1ml = iStochastic( 
          _Symbol,           // symbol 
             PERIOD_M1,        // timeframe 
             5,         // K line period 
             3,          // D line period 
             3,          // slowing 
             MODE_SMA,           // averaging method 
             0,      // price (Low/High or Close/Close) 
             MODE_SIGNAL,             // line index 
             2             // shift 
   );
   total=OrdersTotal();
   if(total<1)
     {
      //--- no opened orders identified
      if(AccountFreeMargin()<(1000*Lots))
        {
         Print("We have no money. Free Margin = ",AccountFreeMargin());
         return;
        }
      //--- check for long position (BUY) possibility
      if( 
        (d1>1 && d5>1 && d9>1  && l5<l1 && l5<l9 && Icc<-85 && Bid < ma20m5 && stoc1h < 40&& stoc1m > stoc1ml)
      ||(d1>1 && d6>1 && d10>1 && l5<l1 && l5<l9 && Icc<-85 && Bid < ma20m5 && stoc1h < 40&& stoc1m > stoc1ml)
      ||(d2>1 && d7>1 && d10>1 && l5<l1 && l5<l9 && Icc<-85 && Bid < ma20m5 && stoc1h < 40&& stoc1m > stoc1ml)
      ||(d1>1 && d7>1 && d10>1 && l5<l1 && l5<l9 && Icc<-85 && Bid < ma20m5 && stoc1h < 40&& stoc1m > stoc1ml)
      ||(d1>1 && d7>1 && d11>1 && l5<l1 && l5<l9 && Icc<-85 && Bid < ma20m5 && stoc1h < 40&& stoc1m > stoc1ml)  //This section is for head and shoulders 1-11
      ||(d2>1 && d7>1 && d11>1 && l5<l1 && l5<l9 && Icc<-85 && Bid < ma20m5 && stoc1h < 40&& stoc1m > stoc1ml)
      ||(d2>1 && d6>1 && d10>1 && l5<l1 && l5<l9 && Icc<-85 && Bid < ma20m5 && stoc1h < 40&& stoc1m > stoc1ml)
      ||(d2>1 && d6>1 && d11>1 && l5<l1 && l5<l9 && Icc<-85 && Bid < ma20m5 && stoc1h < 40&& stoc1m > stoc1ml)
      
      
      ||(d1>1 && d10>1 && d18 && l10<l1 && l10<l18)
      ||(d2>1 && d10>1 && d18 && l10<l2 && l10<l18)
      ||(d3>1 && d10>1 && d18 && l10<l3 && l10<l18)
      ||(d4>1 && d10>1 && d18 && l10<l4 && l10<l18)
      ||(d5>1 && d10>1 && d18 && l10<l5 && l10<l18)
     
      ||(d1>1 && d11>1 && d18 && l11<l1 && l11<l18)
      ||(d2>1 && d11>1 && d18 && l11<l2 && l11<l18)
      ||(d3>1 && d11>1 && d18 && l11<l3 && l11<l18)
      ||(d4>1 && d11>1 && d18 && l11<l4 && l11<l18)
      ||(d5>1 && d11>1 && d18 && l11<l5 && l11<l18)
      
      ||(d1>1 && d12>1 && d18 && l12<l1 && l12<l18)
      ||(d2>1 && d12>1 && d18 && l12<l2 && l12<l18)
      ||(d3>1 && d12>1 && d18 && l12<l3 && l12<l18)
      ||(d4>1 && d12>1 && d18 && l12<l4 && l12<l18)
      ||(d4>1 && d12>1 && d18 && l12<l5 && l12<l18)
      
      ||(d4>1 && d10>1 && d17 && l10<l4 && l10<l17)
      ||(d4>1 && d10>1 && d18 && l10<l4 && l10<l18)
      ||(d4>1 && d10>1 && d19 && l10<l4 && l10<l19)
      ||(d4>1 && d10>1 && d20 && l10<l4 && l10<l20)
      ||(d4>1 && d10>1 && d21 && l10<l4 && l10<l21)
     
      ||(d4>1 && d11>1 && d17 && l11<l4 && l11<l17)
      ||(d4>1 && d11>1 && d18 && l11<l4 && l11<l18)
      ||(d4>1 && d11>1 && d19 && l11<l4 && l11<l19)
      ||(d4>1 && d11>1 && d20 && l11<l4 && l11<l20)
      ||(d4>1 && d11>1 && d21 && l11<l4 && l11<l21)
      
      ||(d4>1 && d12>1 && d17 && l12<l4 && l12<l17)
      ||(d4>1 && d12>1 && d18 && l12<l4 && l12<l18)
      ||(d4>1 && d12>1 && d19 && l12<l4 && l12<l19)
      ||(d4>1 && d12>1 && d20 && l12<l4 && l12<l20)
      ||(d4>1 && d12>1 && d21 && l12<l4 && l12<l21)
      ) 
        {
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"macd sample",16384,0,Green);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
               Print("BUY order opened : ",OrderOpenPrice());
           }
         else
            Print("Error opening BUY order : ",GetLastError());
         return;
        }
      //--- check for short position (SELL) possibility
      if(                                      
        (u1>1 && u5>1 && u9>1  && h5>h1 && h5>h9 && Icc<85 && Ask > ma20m5  && stoc1h > 60&& stoc1m < stoc1ml)
      ||(u1>1 && u6>1 && u10>1 && h5>h1 && h5>h9 && Icc<85 && Ask > ma20m5  && stoc1h > 60&& stoc1m < stoc1ml)
      ||(u2>1 && u7>1 && u10>1 && h5>h1 && h5>h9 && Icc<85 && Ask > ma20m5  && stoc1h > 60&& stoc1m < stoc1ml)
      ||(u1>1 && u7>1 && u10>1 && h5>h1 && h5>h9 && Icc<85 && Ask > ma20m5  && stoc1h > 60&& stoc1m < stoc1ml)     //This section is for head and shoulders 1-11
      ||(u1>1 && u7>1 && u11>1 && h5>h1 && h5>h9 && Icc<85 && Ask > ma20m5  && stoc1h > 60&& stoc1m < stoc1ml)
      ||(u2>1 && u7>1 && u11>1 && h5>h1 && h5>h9 && Icc<85 && Ask > ma20m5  && stoc1h > 60&& stoc1m < stoc1ml)
      ||(u2>1 && u6>1 && u10>1 && h5>h1 && h5>h9 && Icc<85 && Ask > ma20m5  && stoc1h > 60&& stoc1m < stoc1ml)
      ||(u2>1 && u6>1 && u11>1 && h5>h1 && h5>h9 && Icc<85 && Ask > ma20m5  && stoc1h > 60&& stoc1m < stoc1ml)
      
      
      ||(u1>1 && u10>1 && u18 && h10<h1 && h10<h18)
      ||(u2>1 && u10>1 && u18 && h10<h2 && h10<h18)
      ||(u3>1 && u10>1 && u18 && h10<h3 && h10<h18)
      ||(u4>1 && u10>1 && u18 && h10<h4 && h10<h18)
      ||(u5>1 && u10>1 && u18 && h10<h5 && h10<h18)
     
      ||(u1>1 && u11>1 && u18 && h11<h1 && h11<h18)
      ||(u2>1 && u11>1 && u18 && h11<h2 && h11<h18)
      ||(u3>1 && u11>1 && u18 && h11<h3 && h11<h18)
      ||(u4>1 && u11>1 && u18 && h11<h4 && h11<h18)
      ||(u5>1 && u11>1 && u18 && h11<h5 && h11<h18)
     
      ||(u1>1 && u12>1 && u18 && h12<h1 && h12<h18)
      ||(u2>1 && u12>1 && u18 && h12<h2 && h12<h18)
      ||(u3>1 && u12>1 && u18 && h12<h3 && h12<h18)
      ||(u4>1 && u12>1 && u18 && h12<h4 && h12<h18)
      ||(u4>1 && u12>1 && u18 && h12<h5 && h12<h18)
      
      ||(u4>1 && u10>1 && u17 && h10<h4 && h10<h17)
      ||(u4>1 && u10>1 && u18 && h10<h4 && h10<h18)
      ||(u4>1 && u10>1 && u19 && h10<h4 && h10<h19)
      ||(u4>1 && u10>1 && u20 && h10<h4 && h10<h20)
      ||(u4>1 && u10>1 && u21 && h10<h4 && h10<h21)
     
      ||(u4>1 && u11>1 && u17 && h11<h4 && h11<h17)
      ||(u4>1 && u11>1 && u18 && h11<h4 && h11<h18)
      ||(u4>1 && u11>1 && u19 && h11<h4 && h11<h19)
      ||(u4>1 && u11>1 && u20 && h11<h4 && h11<h20)
      ||(u4>1 && u11>1 && u21 && h11<h4 && h11<h21)
     
      ||(u4>1 && u12>1 && u17 && h12<h4 && h12<h17)
      ||(u4>1 && u12>1 && u18 && h12<h4 && h12<h18)
      ||(u4>1 && u12>1 && u19 && h12<h4 && h12<h19)
      ||(u4>1 && u12>1 && u20 && h12<h4 && h12<h20)
      ||(u4>1 && u12>1 && u21 && h12<h4 && h12<h21)
       )// 
        {
         ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+StopLoss*Point,Bid-TakeProfit*Point,"macd sample",16384,0,Red);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
               Print("SELL order opened : ",OrderOpenPrice());
           }
         else
            Print("Error opening SELL order : ",GetLastError());
        }
      //--- exit from the "no opened orders" block
      return;
     }
  }
//+------------------------------------------------------------------+




now im stuck inserting each and every posibilety of the pattern see the if statments lots of them isent there an easyer way to do that like working with arrays maybe ? help !

Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions