Need help check this EA what is the problem

 

Hi all experts here, need your help

I created an EA based on price volatility. It will buy/sell if price jump up/down suddenly. When I compile, no error

but when I test in Strategy Tester, it fails to open any buy/sell order, it gives error 0 in error message

below is the code

you are welcome to modify the code to make it better


//+------------------------------------------------------------------+
//|                                              PriceVolatileEA.mq4 |
//|                                        http://100k2.blogspot.com |
//|                                        http://100k2.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "http://100k2.blogspot.com"
#property link      "http://100k2.blogspot.com"

//--- input parameters
extern double    Lots1min=0.4;
extern double    Lots5min=0.2;
extern double    Lots10min=0.1;
extern int       StopLoss=20;
extern int       TakeProfit=50;
extern int       SlipPage = 3;
extern int       Gap = 15;


//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   double tempprice;
   double gap1min;
   double gap5min;
   double gap10min;
   int ticket;
   
//+------------------------------------------------------------------+
//| 1 minute function                                 |
//+------------------------------------------------------------------+
   
   if ( Close[1] > Close[0] )   //checking sell possibility
   { gap1min = Close[1] - Close[0];
     gap1min =  gap1min*Digits;
     
      if (gap1min > Gap) //checking sell possibility
      ticket=OrderSend(Symbol(),OP_SELL,Lots1min,Bid,SlipPage,0,0,"1 min Sell",111,0,Red);
         
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("Sell order opened : ",OrderOpenPrice());
           }
         else Print("Error opening Sell 1min order : ",GetLastError()); 
         
         Sleep(1000);
         
      if ( (TakeProfit > 0 || StopLoss > 0) &&  ticket>0)
      OrderModify(OrderTicket(), OrderOpenPrice(), Ask+Point*StopLoss,Ask-Point*TakeProfit, 0, 0);
         
   }
   else // checking buy possibility
   { gap1min = Close[0] - Close[1];
     gap1min =  gap1min*Digits;
   
   if (gap1min > Gap) //checking buy possibility
      ticket=OrderSend(Symbol(),OP_BUY,Lots1min,Ask,SlipPage,0,0,"1 min Buy",111,0,Green);
         
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("Buy order opened : ",OrderOpenPrice());
           }
         else Print("Error opening Buy 1min order : ",GetLastError()); 
         
         Sleep(1000);
         
      if ( (TakeProfit > 0 || StopLoss > 0) &&  ticket>0)
      OrderModify(OrderTicket(), OrderOpenPrice(), Bid-Point*StopLoss,Bid+Point*TakeProfit, 0, 0);
         
         
   }
   
   

//+------------------------------------------------------------------+
//| 5 minute function                                 |
//+------------------------------------------------------------------+
   
   if ( Close[5] > Close[0] )   //checking sell possibility
   { gap5min = Close[5] - Close[0];
     gap5min =  gap5min*Digits;
     
      if (gap5min > Gap) //checking sell possibility
      ticket=OrderSend(Symbol(),OP_SELL,Lots5min,Bid,SlipPage,0,0,"5 min Sell",111,0,Red);
         
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("Sell order opened : ",OrderOpenPrice());
           }
         else Print("Error opening Sell 5 min order : ",GetLastError()); 
         
         Sleep(1000);
         
      if ( (TakeProfit > 0 || StopLoss > 0) &&  ticket>0)
      OrderModify(OrderTicket(), OrderOpenPrice(), Ask+Point*StopLoss,Ask-Point*TakeProfit, 0, 0);
         
   }
   else // checking buy possibility
   { gap5min = Close[0] - Close[5];
     gap5min =  gap5min*Digits;
   
   if (gap5min > Gap) //checking buy possibility
      ticket=OrderSend(Symbol(),OP_BUY,Lots5min,Ask,SlipPage,0,0,"5 min Buy",111,0,Green);
         
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("Buy order opened : ",OrderOpenPrice());
           }
         else Print("Error opening Buy 5 min order : ",GetLastError()); 
         
         Sleep(1000);
         
      if ( (TakeProfit > 0 || StopLoss > 0) &&  ticket>0)
      OrderModify(OrderTicket(), OrderOpenPrice(), Bid-Point*StopLoss,Bid+Point*TakeProfit, 0, 0);
         
         
   }
   
   

         
//+------------------------------------------------------------------+
//| 10 minute function                                 |
//+------------------------------------------------------------------+
   
   if ( Close[10] > Close[0] )   //checking sell possibility
   { gap10min = Close[10] - Close[0];
     gap10min =  gap10min*Digits;
     
      if (gap10min > Gap) //checking sell possibility
      ticket=OrderSend(Symbol(),OP_SELL,Lots10min,Bid,SlipPage,0,0,"10 min Sell",111,0,Red);
         
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("Sell order opened : ",OrderOpenPrice());
           }
         else Print("Error opening Sell 10 min order : ",GetLastError()); 
         
         Sleep(1000);
         
      if ( (TakeProfit > 0 || StopLoss > 0) &&  ticket>0)
      OrderModify(OrderTicket(), OrderOpenPrice(), Ask+Point*StopLoss,Ask-Point*TakeProfit, 0, 0);
         
   }
   else // checking buy possibility
   { gap10min = Close[0] - Close[10];
     gap10min =  gap10min*Digits;
   
   if (gap10min > Gap) //checking buy possibility
      ticket=OrderSend(Symbol(),OP_BUY,Lots10min,Ask,SlipPage,0,0,"10 min Buy",111,0,Green);
         
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("Buy order opened : ",OrderOpenPrice());
           }
         else Print("Error opening Buy 10 min order : ",GetLastError()); 
         
         Sleep(1000);
         
      if ( (TakeProfit > 0 || StopLoss > 0) &&  ticket>0)
      OrderModify(OrderTicket(), OrderOpenPrice(), Bid-Point*StopLoss,Bid+Point*TakeProfit, 0, 0);
         
         
   }
   
   
   
   
   
   
   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
Close[0] is not real . . it is simply Bid . . Close[0] cannot actually exist, when bar 0 is actually closed it becomes Bar 1 . . . so if you really want Close[0] use Close[1] at the first tick of Bar 0 . . . otherwise use Bid
 
Gap is 15 . . . gap1min = Close[1] - Close[0]; then gap1min = gap1min*Digits; On a 5 digit broker for GBPUSD Digits will be 5 . . . so it is extremely unlikely that gap1min will ever be greater than 15 . . . maybe you meant to convert Gap to points . . . while you are at it you might want to adjust your code so it handles 4 and 5 digit Brokers . . .
 
this is crazy... I am new into coding and I think you got the variables mixed up. My advice to you is try to build something that's going to help you not, make trades for you.
Reason: