//+------------------------------------------------------------------+
//|                                                 PO_Sell_Stop.mq4 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

#property show_confirm
#property show_inputs

input double Lots = 0.06;
input int Slippage   = 3;
input int Sell_Stop_Distance = 100;
input int StopLoss  = 0;
input int TakeProfit = 100;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   if(!IsExpertEnabled())
        {
         MessageBox("You need to enable AutoTrading! "+" Check your Settings!");
         return;
        }

      if(!IsTradeAllowed())
        {
         MessageBox("You need to Allow Live Trading! "+" Check your Settings!"+"\n"+
                    "Common tab -> Live Trading -> Allow live trading");
         return;
        }
   
   int ticket;
   /*,expiration;*/
   double point;

   point=MarketInfo(Symbol(),MODE_POINT);
   //expiration=CurTime()+PERIOD_D1*60;
   
   double SS_distance_L1 = Bid-Sell_Stop_Distance*point;
   double SS_distance_L2 = Bid-Sell_Stop_Distance*point*2;
   double SS_distance_L3 = Bid-Sell_Stop_Distance*point*3;
   double SS_distance_L4 = Bid-Sell_Stop_Distance*point*4;
   double SS_distance_L5 = Bid-Sell_Stop_Distance*point*5;

   point=MarketInfo(Symbol(),MODE_POINT);
   //expiration=CurTime()+PERIOD_D1*60;
     
   while(true)
     {
      ticket=OrderSend(Symbol(),OP_SELLSTOP,Lots,SS_distance_L1,Slippage,SS_distance_L1+StopLoss*point,SS_distance_L1-TakeProfit*point,NULL,16384,0,clrNONE); // SEL STOP LEVEL 1
      ticket=OrderSend(Symbol(),OP_SELLSTOP,Lots,SS_distance_L2,Slippage,SS_distance_L2+StopLoss*point,SS_distance_L2-TakeProfit*point,NULL,16384,0,clrNONE); // SEL STOP LEVEL 2
      ticket=OrderSend(Symbol(),OP_SELLSTOP,Lots,SS_distance_L3,Slippage,SS_distance_L3+StopLoss*point,SS_distance_L3-TakeProfit*point,NULL,16384,0,clrNONE); // SEL STOP LEVEL 3
      ticket=OrderSend(Symbol(),OP_SELLSTOP,Lots,SS_distance_L4,Slippage,SS_distance_L4+StopLoss*point,SS_distance_L4-TakeProfit*point,NULL,16384,0,clrNONE); // SEL STOP LEVEL 4
      ticket=OrderSend(Symbol(),OP_SELLSTOP,Lots,SS_distance_L5,Slippage,SS_distance_L5+StopLoss*point,SS_distance_L5-TakeProfit*point,NULL,16384,0,clrNONE); // SEL STOP LEVEL 5
      PlaySound("ok.wav");
      if(ticket<=0) Print("Error = ",GetLastError());
      else { Print("ticket = ",ticket); break; }
      //---- 10 seconds wait
      Sleep(10000);
     }   
  }

