MQL5 Ordersend for Binary Options?

 

Hello,

Can somebody help my with the Ordersend for Binary Options in MQL5. I constantly got error:#4756 with all kinds of combinations of variables and values. Below my last atempt:

#define OP_BUY 0            

#define OP_SELL 1  


int OnInit()

  {

//---

      MqlTick last_tick;

      SymbolInfoTick(_Symbol,last_tick);

      double Ask=last_tick.ask; 

      double Bid=last_tick.ask; 

             

      MqlTradeRequest      request={0};

      MqlTradeResult       result={0};

      

      Ask                  = SymbolInfoDouble(_Symbol,SYMBOL_ASK);

      Bid                  = SymbolInfoDouble(_Symbol,SYMBOL_ASK);

    

      request.action       = TRADE_ACTION_DEAL;                     

      request.symbol       = Symbol();  

      request.volume       = 10.0;

      request.price        = NormalizeDouble(Ask,5);

      request.sl           = 0;

      request.tp           = 0;

      request.deviation    = 3;                                     

      request.type         = OP_BUY; 

      request.type_filling = ORDER_FILLING_FOK;

      request.comment      = "BO exp:900"; 

      request.magic        = 1;

     

      bool Ticket=OrderSend(request,result);

      if(Ticket)

        {

         PrintFormat("OrderSend placed successfully. Ticket#=%d",Ticket);

        }

      else

        {

         Print("*** OrderSend failed with error #",GetLastError());

        }

      

//---

   return(INIT_SUCCEEDED);

  }

 
Aart.Koster:

Hello,

Can somebody help my with the Ordersend for Binary Options in MQL5. I constantly got error:#4756 with all kinds of combinations of variables and values. Below my last atempt:

Where did you see that you can trade BO with MT5 ? Never heard that.
 
Aart.Koster:

Can somebody help my with the Ordersend for Binary Options in MQL5.

Try this

Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий

Особенности языка mql5, тонкости и приёмы работы

fxsaber, 2017.07.11 10:50

// Советник возвращает полностью сформированные торговые запросы (включая ручные)
#define TOSTRING(A)  #A + " = " + (string)(A) + "\n"
#define TOSTRING2(A) #A + " = " + EnumToString(A) + " (" + (string)(A) + ")\n"

string ToString( const MqlTradeRequest &Request )
{
  return(TOSTRING2(Request.action) + TOSTRING(Request.magic) + TOSTRING(Request.order) +
         TOSTRING(Request.symbol) + TOSTRING(Request.volume) + TOSTRING(Request.price) + 
         TOSTRING(Request.stoplimit) + TOSTRING(Request.sl) +  TOSTRING(Request.tp) + 
         TOSTRING(Request.deviation) + TOSTRING2(Request.type) + TOSTRING2(Request.type_filling) +
         TOSTRING2(Request.type_time) + TOSTRING(Request.expiration) + TOSTRING(Request.comment) +
         TOSTRING(Request.position) + TOSTRING(Request.position_by));
}

void OnTradeTransaction(   const MqlTradeTransaction&, const MqlTradeRequest& Request, const MqlTradeResult& )
{
  if (Request.action)
    Print(ToString(Request));
}

Если возникает проблема с тем же Filling, запустите этот советник и создайте нужный вам ордер вручную (F9 в терминале). Сформированный торговый запрос будет распечатан советником.

К сожалению, на реальных счетах это сделать проблематично. Предложение разработчики отклонили.

 
fxsaber:

Try this


Hi Alain, You can trade BO's on MT5 at acefx24.com.

And Thank you fxaber for your suggestion, but I still got error #4756.

 
Aart.Koster:

Hi Alain, You can trade BO's on MT5 at acefx24.com.

And Thank you fxaber for your suggestion, but I still got error #4756.

Thanks.

You need to check result.retcode to know the exact error. Error #4756 is generic trading error, which is useless by itself.

 
Aart.Koster:

Hi Alain, You can trade BO's on MT5 at acefx24.com.

And Thank you fxaber for your suggestion, but I still got error #4756.

Broker-Bug.

 
Aart.Koster:

Hi Alain, You can trade BO's on MT5 at acefx24.com.

And Thank you fxaber for your suggestion, but I still got error #4756.

Aart.Koster, do you know other brokers that provide binary options on MT5?