OrderSend() - not working out for real-time orders (4756 error code)

 

Hi all,

In advance - thanks for your help and suggestions.


If I run this (just a test - no exception handling or practical application as yet) on the ONIT() function:

      MqlTradeRequest request; 

      MqlTradeResult result; 



      request.symbol = Symbol();

      request.volume = 0.1; 

      request.action = TRADE_ACTION_PENDING; 

      request.type = ORDER_TYPE_BUY_STOP; 

      request.price = 1.208; 

      request.sl=0;                             

      request.tp=0;                                 

      request.deviation=5; 

      request.type_filling = ORDER_FILLING_FOK;

      OrderSend(request, result);




This works fine - - - If however, I run this:

SymbolInfoTick(Symbol(), tick);

      MqlTradeRequest request; 

      MqlTradeResult result; 



      request.symbol = Symbol();

      request.volume = 0.1; 


      request.action = TRADE_ACTION_DEAL;

      request.type = ORDER_TYPE_BUY;

      request.price = tick.ask;


      request.sl=0;                             

      request.tp=0;                                 

      request.deviation=5; 

      request.type_filling = ORDER_FILLING_FOK;

      OrderSend(request, result);

I get nothing... (4756 error code returned) 


So I can place pending orders - but cannot place at-market price orders.


FYI - I've printed the tick.ask attribute to the console and its fine - a normal 5 digit double-type response.

I've even applied NormalizeDouble() to tick.ask return value in the hopes that may standardise some aspect of it.



Please... any ideas?


Thanks again

 
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code correctly in a new post.
 

Thanks Keith - done now


Regards

 

Does any one have any ideas? I've seen queries on this before and cannot find any answers - any help would be great


Thanks alot

 
Could you print out the result structure, maybe?
 

Thank you for engaging to help - I really appreciate it

I THINK I may have the answer (bout would love some verification from a veteran)


When running


OrderSend(request, result) ;

Print(result.retcode);

The return code I'm getting is 10030

This error is a:  TRADE_RETCODE_INVALID_FILL

The implication being my broker does not support FOK

request.type_filling = ORDER_FILLING_FOK;


Some googling later suggested to use

Print(SymbolInfoInteger( _Symbol, SYMBOL_FILLING_MODE))

to which I got the response:  2

By all accounts the number response to the 3 fill type options.

FOK == 1

IOC == 2

Return == 3


Essentially - I cannot execute FOK with my broker (and need to use IOC).


I'll need to test out if this is 100% the case in the morning as I'm now getting a different error code - 10018 (Markets Closed) :D

Anything further I should maybe look at? Thanks again in advance