Logs a String to a File

Code in mql5:


//define parameter  
string filename; 
filename = _Symbol + "-" + IntegerToString(dt.mon) + "-" + IntegerToString(dt.day) + ".txt"; 

void Write(string str)
{
int handle;
handle = FileOpen(filename, FILE_READ|FILE_WRITE|FILE_CSV, "/t");
FileSeek(handle, 0, SEEK_END);
FileWrite(handle, str + " Time " + TimeToString(TimeCurrent(), TIME_DATE|TIME_SECONDS));
FileClose(handle);
}

check the trade request before sending with the function OrderCheck()

From class CTrade:

bool CTrade::PositionOpen(const string symbol,ENUM_ORDER_TYPE order_type,double volume,
double price,double sl,double tp,const string comment)
{
string action,result;
//---
ClearStructures();
//--- checking
if(order_type!=ORDER_TYPE_BUY && order_type!=ORDER_TYPE_SELL)
{
m_result.retcode=TRADE_RETCODE_INVALID;
m_result.comment="Invalid order type";
return(false);
}
//--- setting request
m_request.action =TRADE_ACTION_DEAL;
m_request.symbol =symbol;
m_request.magic =m_magic;
m_request.volume =volume;
m_request.type =order_type;
m_request.price =price;
m_request.sl =sl;
m_request.tp =tp;
m_request.deviation =m_deviation;
m_request.type_filling=m_type_filling;
m_request.comment =comment;
//--- order check
if(!OrderCheck(m_request,m_check_result))
{
m_result.retcode=m_check_result.retcode;
printf(__FUNCTION__+": %s [%s]",FormatRequest(action,m_request),FormatRequestResult(result,m_request,m_result));
//--- copy return code
return(false);
}
//--- order send
if(!OrderSend(m_request,m_result))
{
printf(__FUNCTION__+": %s [%s]",FormatRequest(action,m_request),FormatRequestResult(result,m_request,m_result));
return(false);
}
printf(__FUNCTION__+": %s [%s]",FormatRequest(action,m_request),FormatRequestResult(result,m_request,m_result));
//--- ok
return(true);
}

declare array with two data types string and double

Code in mql5:

struct string_double
{
string str_val;
double dbl_val;
}

string_double MyArray[SIZE];

//....

MyArray[0].str_val = "Hello, I'm string :)";
MyArray[0].dbl_val = 1;