EA with Slippage=0?

Albalunga
79

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
480
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
79
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
480
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.

JIHUN NAM
821
JIHUN NAM  
Code2219 or 2319:

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


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


Best regards,

William Roeder
27524
William Roeder  
JIHUN NAM: Mate,  where should I put this code??   it shows errors
MT4: Learn to code it.
MT5: Begin learning to code it.
  1. If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.
  2. or pay (Freelance) someone to code it.
              Hiring to write script - General - MQL5 programming forum
We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help