I want to prepare an EA that will send limit orders as market orders whan price is rached. Example.In Eur/USD price is 1.16593 and is going down and the EA want to buy at 1.16574. When price reaches that price, the EA sends a market order.
The problem is to avoid ANY negative slippage even if there is a delay in execution. That is to buy exactly at 1.16574 or less not more than that price, neither for the fifth decinmal digit. Is it possible to do an EA in MQL$ with this feature?
here's what i'v read and know :
slippage you set when sending orders, is simply ignored in MarketExecution.if you want Zero slippage : go with Instant Execution mode, though probably most of your orders will not lead to positions (fail to be executed) because of price changesspecially on market harsh times.
Thanks for your answer. This would be good, it is not a problem if the order is not exectued in that moment. But can you be clearer? I see your link but I don't well understand what it means. It doesn't seem a part of code to insert in the EA.What would be useful is a code to insert in an EA that can run in every instrument and broker. If it exists....
I mean you should first check if InstantExecution is allowed for the symbol you wanna trade in :
MySymbolExeMode = (ENUM_SYMBOL_TRADE_EXECUTION) SymbolInfoInteger(_Symbol, SYMBOL_TRADE_EXEMODE);
if(MySymbolExeMode == SYMBOL_TRADE_EXECUTION_INSTANT)
// rest of your code ......
// send orders with desired slippage you set...
// though your orders won't get executed if slippage occurs (i.e. you get requotes from server)
else if(MySymbolExeMode == SYMBOL_TRADE_EXECUTION_MARKET)
// send orders with any slippage you set , slippage is ignored.
// (positions OpenPrice (may vary) varies from your request when sending orders)
// but you won't get requotes.
ByTheWay, I don't know what are these two execution modes : SYMBOL_TRADE_EXECUTION_REQUEST and SYMBOL_TRADE_EXECUTION_EXCHANGE.
ByTheWay, I don't know what are these two execution
modes : SYMBOL_TRADE_EXECUTION_REQUEST and SYMBOL_TRADE_EXECUTION_EXCHANGE.
Mate, where should I put this code?? it shows errors
'MySymbolExeMode' - unexpected token, probably type is missing? XXXXX.mq4 21 1
'MySymbolExeMode' - variable already defined XXXXX.mq4 21 1 see
previous declaration of variable 'MySymbolExeMode' XXXXXX.mq4 20 29'if'
- expressions are not allowed on a global scope XXXXX.mq4 22 1
Please enable the necessary setting in your browser, otherwise you will not be able to log in.