input string infoOrders = "___ORDER SETTINGS___"; //.
input double volume = 0.01; //Volume
input double SLPipsInp = 20; //SL pips
input double TPPipsInp = 20; //TP pips
input string comment = "Aqua EA"; //Comment
input int magicNumber = 194783; //Magic nr
input int maxAllowedSlippageInp = 3; //Max allowed slippage pips

input string gap1 = ""; //.
input string infoIndicator = "___INDICATOR SETTINGS___"; //.
input string indicatorName = "te"; //Indicator exact name
extern int BBandsPeriod = 20;
extern double BBandsDeviation = 2.0;
extern int MAPeriod = 50;
extern int MACD_Fast = 30;
extern int MACD_Slow = 50;
extern int MACD_SMA = 7;
extern int MAMode = MODE_SMA;
extern int MAPrice = PRICE_CLOSE;
extern int MAShift = 0;
input bool Platform_Alert = true;
input bool Mobile_Alert = true;
input bool Email_Alert = true;
input int Alert_Repeat = 1;
input int Alert_Interval = 1;
//+------------------------------------------------------------------+
//| Includes                                                         |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Variables                                                        |
//+------------------------------------------------------------------+
double SLPips,TPPips;
//**--TEMPLATE
datetime stopper=Time[0];
int digiter, normalizer, maxAllowedSlippage;
double lotStep;
//+------------------------------------------------------------------+
//|                       TEMPLATE FUNCTIONS                         |
//|                                                                  |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Is new bar                                                       |
//+------------------------------------------------------------------+
bool isNewBar() {
   if (stopper == Time[1]) {
      stopper = Time[0];
      return true;
   } else {
      return false;
   }
}
//+------------------------------------------------------------------+
//|                           FUNCTIONS                              |
//|                                                                  |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Send order                                                       |
//+------------------------------------------------------------------+
void SendOrder(bool isLong) {
   double TP,SL;
   if (isLong) {
      if (TPPips!=0) {
         TP=NormalizeDouble(Bid+TPPips*Point,Digits());
      } else {
         TP=0;
      }
      if (SLPips!=0) {
         SL=NormalizeDouble(Bid-SLPips*Point,Digits());
      } else {
         SL=0;
      }
      int L=OrderSend(Symbol(),OP_BUY,volume,Ask,maxAllowedSlippage,SL,TP,comment,magicNumber,0,0);
      if (L<0) {
         Alert("Ordersend error: "+IntegerToString(GetLastError()));
      }
   } else {
      if (TPPips!=0) {
         TP=NormalizeDouble(Ask-TPPips*Point,Digits());
      } else {
         TP=0;
      }
      if (SLPips!=0) {
         SL=NormalizeDouble(Ask+SLPips*Point,Digits());
      } else {
         SL=0;
      }
      int S=OrderSend(Symbol(),OP_SELL,volume,Bid,maxAllowedSlippage,SL,TP,comment,magicNumber,0,0);
      if (S<0) {
         Alert("Ordersend error: "+IntegerToString(GetLastError()));
      }
   }
}

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
  
   //**--TEMPLATE
   lotStep = MarketInfo(Symbol(), MODE_LOTSTEP);   
   if (lotStep==0.01) {
      normalizer=2;
   } else if (lotStep==0.1) {
      normalizer=1;
   } else if (lotStep==1) {
      normalizer=0;
   }
   
   maxAllowedSlippage=maxAllowedSlippageInp;
   SLPips=SLPipsInp;
   TPPips=TPPipsInp;
   
   if (Digits==3 || Digits==5) {
      digiter=10;
      maxAllowedSlippage*=10;
      SLPips*=10;
      TPPips*=10;
   } else {
      digiter=1;
   }
   

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
      if (isNewBar()) {
         if (LongEntry()) {
            SendOrder(true);
         }
         if (ShortEntry()) {
            SendOrder(false);
         }
      }
   
  }
//+------------------------------------------------------------------+