//+------------------------------------------------------------------+
//|   MyBuy.mq4
//+------------------------------------------------------------------+
#include <stdlib.mqh>
#include <WinUser32.mqh>

extern double Lots = 0.5;
extern double StopLoss = 20;
extern double TakeProfit = 0;

double SL,TP,Spread;

int start()
{
   RefreshRates();

   SL = NormalizeDouble(Ask-(StopLoss*Point),Digits);
   if (TakeProfit > 0)
   {TP = NormalizeDouble(Ask+(TakeProfit*Point),Digits);}
   else
   {TP = 0;}

   int ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,0,SL,TP);

   if(ticket<1)
   {
      int error=GetLastError();
      Comment("\nError = ",ErrorDescription(error));
      return;
   }
   else
   {Comment(" ");}

   return(0);
}
//+------------------------------------------------------------------+