//+------------------------------------------------------------------+
//|                                                  Buy Order-1.mq4 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property show_inputs

#include <stderror.mqh>
#include <stdlib.mqh>

//parameternya ini, input-nya ini
extern double LOT =   0.30;
extern int    TP  =   16;
extern int    TP2 =   46;
extern int    SL  =   15;
//---------------------------
string        MySym    =     "";
int       MyDigits     =      5;
double    MyPoints     = 0.0001;


//+------------------------------------------------------------------+
//| Custom initialization function |
//+------------------------------------------------------------------+
int init()
  {
       MySym = Symbol();   
   MyPoints  = MarketInfo( MySym, MODE_POINT  );
   MyDigits  = MarketInfo( MySym, MODE_DIGITS );
   //---
        if( MyPoints == 0.001   ) { MyPoints = 0.01;   MyDigits = 3; }
   else if( MyPoints == 0.00001 ) { MyPoints = 0.0001; MyDigits = 5; }
   
   return(0);
  }
//+------------------------------------------------------------------+
// +
//+------------------------------------------------------------------+
int start()
{
    RefreshRates();
    while( IsTradeContextBusy() ) { Sleep(100); }
//----
     double Stop  = NormalizeDouble(Ask - (SL  * MyPoints),MyDigits);
     double Prof1 = NormalizeDouble(Ask + (TP  * MyPoints),MyDigits);
     double Prof2 = NormalizeDouble(Ask + (TP2 * MyPoints),MyDigits);
      
     int ticket = OrderSend(MySym,OP_BUY,LOT,Ask,NormalizeDouble(3 * MyPoints,MyDigits),Stop,Prof1,"contest",1,0,CLR_NONE);
                  OrderSend(MySym,OP_BUY,LOT,Ask,NormalizeDouble(3 * MyPoints,MyDigits),Stop,Prof2,"contest",2,0,CLR_NONE);
         if(ticket<1)
            {
             int error=GetLastError();
             Print("Error = ",ErrorDescription(error));
             return (0);
            }
//----
   OrderPrint();
return(0);
}
