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);
}

No comments:

Post a Comment