MQL Connector Library
In this chapter we will learn how to use the MT2IQ library to send signals directly from MQL code (either indicator or expert advisor).
Requirements:
In order to use MT2IQ library make sure the library (mt2iq_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 "mt2iq_connector_lib.ex5"
bool mt2iq (string symbol, string type, double amount, int expiryminutes);
#import
datetime signaltime;

#import "mt2iq_connector_lib.ex4"
bool mt2iq (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])
{
mt2iq(Symbol(), "CALL", 10, 5);
signaltime = time[0];
}
if (DOWN_Arrow_Condition && signaltime != time[0])
{
mt2iq(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])
{
mt2iq(Symbol(), "CALL", 10, 5);
signaltime = time[0];
}
if (DOWN_Arrow_Condition && signaltime != time[0])
{
mt2iq(Symbol(), "PUT", 10, 5);
signaltime = time[0];
}
//...
return(rates_total);
}

The first parameter of the mt2iq 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.