EA with Slippage=0?

To add comments, please log in or register
Albalunga
57
Albalunga  

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?

Thanks

Code2219 or 2319
489
Code2219 or 2319  

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 changes
specially on market harsh times.

Albalunga
57
Albalunga  
Code2219 or probably 2319:

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 changes
specially 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....

Thanks

Code2219 or 2319
489
Code2219 or 2319  

I mean you should first check if InstantExecution is allowed for the symbol you wanna trade in :

ENUM_SYMBOL_TRADE_EXECUTION MySymbolExeMode;
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.

To add comments, please log in or register