what's wrong with my EA

 

why my EA does not open orders? someone help please!!

//+------------------------------------------------------------------+
//|                                                        SHAUL.mq4 |
//|                                                        |
//|                                                http://ftsa.co.il |
//+------------------------------------------------------------------+
#property link      ""
#include <stderror.mqh>
#include <stdlib.mqh>
#define IDLE 0
#define SIGNAL_BUY   1
#define SIGNAL_SELL  2
#define SIGNAL_TRBUY 3
#define SIGNAL_TRSELL 4
#define SIGNAL_P 5
#define SIGNAL_L 6
bool trade=false;
int tickets=0;
int ticketb=0;
int Order = IDLE;
int Barw;
int barc;
double BOLH;
double BOLL;

extern int TP=120;    //take profit
extern int SL=60;      //stop loss
extern double lotSize=0.1;
extern double DEV=3.0;
extern int Per=12;
extern int Bar_wait=10;
extern int MagicNumber=7272;



//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{
//----
   if (OrdersTotal()==0)   
   {trade=false;}

   if (OrdersTotal()!=0)
   {
       for (int i=1; i<=OrdersTotal(); i++)       //Cycle for all orders..
      {                                        //displayed in the terminal
       if(OrderSelect(i-1,SELECT_BY_POS)==true)//If there is the next one
        {                                     
          if (OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
          {
           trade=true;
           
               break;
            }
          else {trade=false;}
          }
        } 
     
   } 


//////////////////// INDICATORS\

BOLH=iCustom(NULL,0,"Bands",Per,0,DEV,MODE_UPPER,1);////the last zero its the shift   
BOLL= iCustom(NULL,0,"Bands",Per,0,DEV,MODE_LOWER,1);////the last zero its the shift 
Comment("bollh = " ,BOLH); // show us the price of the boll high


//////////////////CHECK FOR BUY

if (trade==false && Order==IDLE)
{

if (  Open[0]<=BOLL && Open[1]<BOLL )

{Order=SIGNAL_BUY;}
    Alert("buy_signal");
      
}
//////////////////////////////


//////////////////CHECK FOR SELL

if (trade==false && Order==IDLE)
{

if (  Open[0]>=BOLH && Open[1]>=BOLH )

{Order=SIGNAL_SELL;}
      Alert("sell_signal");
      
}

/////////////////////////BUY
if (trade==false)
{
  if (Order == SIGNAL_BUY  )
  {

  ticketb=OrderSend(Symbol(),OP_BUY,lotSize,Ask,3,0, 0,"SHAUL",MagicNumber,Green);   //open
  OrderModify(ticketb,0,Ask-(SL*Point),Ask+(TP*Point),0,Green);

      if(OrderSelect( ticketb, SELECT_BY_TICKET )==true)
      {
       Alert("LONG ORDER OPENED IN SHAUL"," Symbol= ",Symbol()," Period=",Period(), " Ticket= ",ticketb);
      Order = SIGNAL_TRBUY;
      
       
        
      }
      else
      {
      Print("OrderSelect returned the error of ",GetLastError());
      Alert("EROR LONG ORDER IN SHAUL "," Symbol= ",Symbol()," Period=",Period()," EROR= ",GetLastError());
      Order= IDLE;
      }
   }
} 
/////////////////////////////////// END


/////////////////////////sell
if (trade==false)
{
  if (Order == SIGNAL_SELL  )
  {

  tickets=OrderSend(Symbol(),OP_SELL,lotSize,Bid,3,0, 0,"SHAUL",MagicNumber,Green);
  OrderModify(tickets,0,Ask+(SL*Point),Ask-(TP*Point),0,Green);

      if(OrderSelect( tickets, SELECT_BY_TICKET )==true)
      {
       Alert("SHORT ORDER OPENED IN SHAUL"," Symbol= ",Symbol()," Period=",Period(), " Ticket= ",ticketb);
      Order = SIGNAL_TRSELL;
      
        
      }
      else
      {
      Print("OrderSelect returned the error of ",GetLastError());
      Alert("EROR SHORT ORDER IN SHAUL "," Symbol= ",Symbol()," Period=",Period()," EROR= ",GetLastError());
      Order= IDLE;
      }
   }
} 
/////////////////////////////////// END


//----
   return(0);
  }
//+------------------------------------------------------------------+
 

I've just answered your other inquire. Try not to post so many times on the same subject. Programmers here don't like that. You'll end up Not getting help from some really good people.

Ps: if you're anything like me, then you'll need to code small and work your way to big. Don't submit such a huge code instead try to understand about 4 lines of code and submit your question based on those.

Reason: