invalid trade request

To add comments, please log in or register
samjesse
645
samjesse  

Hi

This mql5 code produced error 10013 "invalid request" which I don't know why, Could some one please help?

Thank you

MqlTradeRequest tradeRequest;
MqlTradeResult  tradeResult;
int     factore                 = StringFind(Symbol(), "JPY", 0) >= 0 ? 100 : 10000;
double _Ask 			= SymbolInfoDouble(_Symbol, SYMBOL_ASK);

double  takeProfitPoints        = 22 / factore;
double  stopLossPoints          = 99 / factore;

double takeProfitPrice          = NormalizeDouble(_Ask - takeProfitPoints, _Digits);
double stopLossPrice            = NormalizeDouble(_Ask + stopLossPoints, _Digits);
double lots                     = StringToDouble(result[2]);
tradeRequest.action             = TRADE_ACTION_PENDING;
tradeRequest.symbol             = _Symbol;
tradeRequest.volume             = 0.01;
tradeRequest.price              = SymbolInfoDouble(_Symbol, SYMBOL_BID);
tradeRequest.sl                 = stopLossPrice;
tradeRequest.tp                 = takeProfitPrice;
tradeRequest.deviation          = 2;
tradeRequest.type               = ORDER_TYPE_SELL_LIMIT;
tradeRequest.type_filling       = ORDER_FILLING_FOK;

bool success                    = OrderSend(tradeRequest,tradeResult);  // GIVES FALSE
Print(tradeResult.retcode);     // GIVES 10013 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
fxsaber
10288
fxsaber  
MqlTradeRequest tradeRequest = {0};
To add comments, please log in or register