Thursday, June 14, 2018

Buy Sell trade open same time

If you want open buy and sell trade at same time then copy this code and paste in script folder of MT4. This script open buy sell trade for you at same time.
Open MT4 and click right click on Script folder then create new editor , choose script and give name of file send_buy&sell and paste this code then compile.
Now just drag and down on MT4 screen and you seen EA created order for you.
You need to everytime darg and down if you want new order.

//+------------------------------------------------------------------+
//|                                                send_buy&sell.mq4 |
//+------------------------------------------------------------------+

//---- Parametres Externes
extern double   BuyLots = 0.01;
extern int      BuyStopLoss = 100;
extern int      BuyTakeProfit = 100;
extern double   SellLots = 0.01;
extern int      SellStopLoss = 100; 
extern int      SellTakeProfit = 100;

//+------------------------------------------------------------------+
//| script "send pending order with expiration data"                 |
//+------------------------------------------------------------------+
int start()
  {
   int    ticket,expiration;
   double point;
//----
   point=MarketInfo(Symbol(),MODE_POINT);
   expiration=CurTime()+PERIOD_M15*60;
//----
   while(true)
     {
      ticket=OrderSend(Symbol(),OP_SELL,SellLots,Bid,0,Bid+SellStopLoss*Point,Bid-SellTakeProfit*Point,"SELL",NULL,0,Red);
      if(ticket<=0) Print("Error = ",GetLastError());
      else { Print("ticket = ",ticket); break; }
      //---- 10 seconds wait
      Sleep(10);
     }
     while(true)
     {
      ticket=OrderSend(Symbol(),OP_BUY,BuyLots,Ask,0,Ask-BuyStopLoss*Point,Ask+BuyTakeProfit*Point,"BUY",NULL,0,Lime);
      if(ticket<=0) Print("Error = ",GetLastError());
      else { Print("ticket = ",ticket); break; }
      //---- 10 seconds wait
      Sleep(10);
     }
//----
   return(1);
  }
//+------------------------------------------------------------------+

No comments:

Post a Comment