You have to understand how it works.
0 is 0 but deviation is not used on Market execution.
- 2014.04.10
- www.mql5.com
You have to understand how it works.
0 is 0 but deviation is not used on Market execution.
Thanks for your quick answer Alain.
I am lost, I saw your post about instant execution (only for market makers if I understand correctly, not ECN), but I can't see how it fits with the OrderSend function : there is no mention to the enum ENUM_SYMBOL_TRADE_EXECUTION (one of its value is SYMBOL_TRADE_EXECUTION_INSTANT) in the function spec.
Also, here there is an exemple of what I am doing now: https://www.mql5.com/en/docs/constants/tradingconstants/enum_trade_request_actions
Code is :
#define EXPERT_MAGIC 123456 // MagicNumber of the expert //+------------------------------------------------------------------+ //| Opening Buy position | //+------------------------------------------------------------------+ void OnStart() { //--- declare and initialize the trade request and result of trade request MqlTradeRequest request={0}; MqlTradeResult result={0}; //--- parameters of request request.action =TRADE_ACTION_DEAL; // type of trade operation request.symbol =Symbol(); // symbol request.volume =0.1; // volume of 0.1 lot request.type =ORDER_TYPE_BUY; // order type request.price =SymbolInfoDouble(Symbol(),SYMBOL_ASK); // price for opening request.deviation=5; // allowed deviation from the price request.magic =EXPERT_MAGIC; // MagicNumber of the order //--- send the request if(!OrderSend(request,result)) PrintFormat("OrderSend error %d",GetLastError()); // if unable to send the request, output the error code //--- information about the operation PrintFormat("retcode=%u deal=%I64u order=%I64u",result.retcode,result.deal,result.order); }
Why do they set deviation if it is not taken into account??
- www.mql5.com
Thanks for your quick answer Alain.
I am lost, I saw your post about instant execution (only for market makers if I understand correctly, not ECN), but I can't see how it fits with the OrderSend function : there is no mention to the enum ENUM_SYMBOL_TRADE_EXECUTION (one of its value is SYMBOL_TRADE_EXECUTION_INSTANT) in the function spec.
Execute such code to check with trade execution mode is used :
ENUM_SYMBOL_TRADE_EXECUTION executionMode=(ENUM_SYMBOL_TRADE_EXECUTION)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_EXEMODE); printf("Trade execution mode for %s is %s",_Symbol,EnumToString(executionMode));If it returns SYMBOL_TRADE_EXECUTION_INSTANT (or SYMBOL_TRADE_EXECUTION_REQUEST) then you can use "deviation" with OrderSend. Otherwise you can't.
Also, here there is an exemple of what I am doing now: https://www.mql5.com/en/docs/constants/tradingconstants/enum_trade_request_actions
Code is :
Why do they set deviation if it is not taken into account??
Because OrderSend() is a generic function, used with all kind of trading environment.
Execute such code to check with trade execution mode is used :
If it returns SYMBOL_TRADE_EXECUTION_INSTANT (or SYMBOL_TRADE_EXECUTION_REQUEST) then you can use "deviation" with OrderSend. Otherwise you can't.Because OrderSend() is a generic function, used with all kind of trading environment.
Your code returns
2018.05.08 14:33:53.876 test ([STOXX50],H1) Trade execution mode for [STOXX50] is SYMBOL_TRADE_EXECUTION_MARKET
So I can not use deviation with OrderSend. Do you know if I can use deviation with another function, or I just can't use deviation at all with my broker?
Your code returns
2018.05.08 14:33:53.876 test ([STOXX50],H1) Trade execution mode for [STOXX50] is SYMBOL_TRADE_EXECUTION_MARKET
So I can not use deviation with OrderSend. Do you know if I can use deviation with another function, or I just can't use deviation at all with my broker?
I know this post is an old one. So sorry to bother you here ^^
I was having the same problem. So your post helped me to understand than my broker will not help me on this side.
Anyway, you can (if you are still there or if other are reading)
Use pending orders ;) Should be only limit ^^ And add something like living time of the order of 1 second you will have the equivalent of a fill or kill with 0 deviation order no ?
Have a nice day :) (if anyone have better idea i'm all ears !)
I know this post is an old one. So sorry to bother you here ^^
I was having the same problem. So your post helped me to understand than my broker will not help me on this side.
Anyway, you can (if you are still there or if other are reading)
Use pending orders ;) Should be only limit ^^ And add something like living time of the order of 1 second you will have the equivalent of a fill or kill with 0 deviation order no ?
Have a nice day :) (if anyone have better idea i'm all ears !)
Pending orders also suffer slippage! You cannot prevent slippage with pending orders, whether that be negative or positive slippage.
Most good traders search for brokers that are ECN or NDD, and stay away from market makers or DD. Searching for those types of brokers because you want "Instant Execution" just to be able to have control over deviation, is setting yourself up to lose money.
Learn to embrace slippage by understanding it and how to trade with it!
Pending orders also suffer slippage! You cannot prevent slippage with pending orders, whether that be negative or positive slippage.
Most good traders search for brokers that are ECN or NDD, and stay away from market makers or DD. Searching for those types of brokers because you want "Instant Execution" just to be able to have control over deviation, is setting yourself up to lose money.
Learn to embrace slippage by understanding it and how to trade with it!
If I wrong please correct.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have a mql5 EA which sends market orders with the command
OrderSend(request,result)
The MqlTradeRequest request object has the following attributes:
request.action = TRADE_ACTION_DEAL; (market execution)
request.deviation=0; (I prefer not executing the trade rather than executing it with any deviation, I am doing arbitrage and any point counts)
In the facts, orders do execute with deviation (or slippage, I guess it is the same) : between 1 and 2 points, which ruins my trading.
My questions are:
- is that possible to set request.deviation to 0 in theory, or a 0 value is interpreted as no max deviation specified?
- if that is not possible, is there any minimum value (0.1 would be ok?)
- is it mandatory for the broker to respect the max deviation specified, or is he allowed to forget it? I think I read somewhere that ECN brokers do not respect it, and market makers have to respect it...
Thanks for your help!
Pierre