MQL Connector Library

In this chapter we will learn how to use the mt2binary library to send signals directly from MQL code (either indicator or expert advisor).

Requirements:

In order to use mt2binary library make sure the library (mt2binary_connector_lib for MT4/5) is copied to your MetaTrader terminal's library folder (MQL4/Libraries or MQL5/Libraries).

Declare the functions in your indicator or EA at the top of your code with #import:

#import "mt2binary_connector_lib.ex5"
bool mt2binary (string symbol, string type, double amount, int expiryminutes);
#import

datetime signaltime;

#import "mt2binary_connector_lib.ex4"
bool mt2binary (string symbol, string type, double amount, int expiryminutes);
#import

datetime signaltime;

Example for placing Up/Down trades on Up_Arrow_Condition and Down_Arrow_Condition:

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   
   //...

 

   ArraySetAsSeries(time,true); // ---> only in MQL5


   bool Up_Arrow_Condition = ...

   bool Down_Arrow_Condition = ...


   if (UP_Arrow_Condition && signaltime != time[0])
   {
      mt2binary(Symbol(), "CALL", 10, 5);
      signaltime = time[0];
   }

   if (DOWN_Arrow_Condition && signaltime != time[0])
   {
      mt2binary(Symbol(), "PUT", 10, 5);     

      signaltime = time[0];   

   }
 

 

   //...


   return(rates_total);
  }

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   
   //...

 

   ArraySetAsSeries(time,true); // ---> only in MQL5


   bool Up_Arrow_Condition = ...

   bool Down_Arrow_Condition = ...


   if (UP_Arrow_Condition && signaltime != time[0])
   {
      mt2binary(Symbol(), "CALL", 10, 5);
      signaltime = time[0];
   }

   if (DOWN_Arrow_Condition && signaltime != time[0])
   {
      mt2binary(Symbol(), "PUT", 10, 5);     

      signaltime = time[0];   

   }
 

 

   //...


   return(rates_total);
  }

The first parameter of the mt2binary function is a symbol <string> (currency pair or asset available on iqoption.com), e.g. "EURUSD". The second parameter is the contract type <string>: "CALL" for up-trade or "PUT" for down-trade. The third parameter is the amount <double>, the trade amout you will invest. The last parameter is the expiration time <int> in minutes.

In order to avoid the redundant trades on same candle, please do not forget to include in the if-condition signaltime != time[0] and to set the variable signaltime = time[0] in the if-expression part as shown in the example code above.

Contact E-mail:

info@mt2binary.com

  • YouTube Social  Icon
  • Facebook Social Icon

© 2017 - 2019 MT2Binary. All right reserved

MT2BINARY functions with the Binary.com™ platform, but it is 3rd party software.

We are not partners of Binary.com™.