Download MetaTrader 5

Problem with trade action deal

To add comments, please log in or register
Kheops_888
19
Kheops_888  

Good morning every one,

Im sory for my question, it was already posted but i do not understand even more.

I just want to open a simple BUY or SELL on an EA, it works great but some times i've got this message :

2015.01.21 23:09:51.127    Trades    '676751': failed market sell 0.10 GBPNZD [No prices]


My EA open multi orders on different currency.


This is an example of the code :

    MqlTradeRequest requete={0};
    requete.action=TRADE_ACTION_DEAL;
    requete.price=SymbolInfoDouble("GBPNZD",SYMBOL_ASK);
    requete.magic=129;
    requete.symbol="GBPNZD";
    requete.volume=lots;
    requete.type=ORDER_TYPE_BUY;
    MqlTradeResult resultat2={0};

    OrderSendAsync(requete2,resultat2);


I'read on the forum that it is not necessary to indicate the price, but it's the same without. (sometimes message : [no prices])

Note : the problem appears approximativly 1 times on 5.

Thank you very much, and again sorry for this question already posted.


Alain Verleyen
Moderator
31184
Alain Verleyen  

What is the trading return code ? resultat2.retcode

What is the execution type for this symbol ? SymbolInfoInterger("GBPNZD",SYMBOL_TRADE_EXEMODE) ?

Kheops_888
19
Kheops_888  

Thank you,

Im'sorry, i don't have recuperated the resultat2.retcode.

But i can give you the execution type : 2, Instant execution type (https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants#enum_symbol_trade_mode).

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Symbol Properties - Reference on algorithmic/automated trading language for MetaTrader 5
Alain Verleyen
Moderator
31184
Alain Verleyen  
Kheops_888:

Thank you,

Im'sorry, i don't have recuperated the resultat2.retcode.

But i can give you the execution type : 2, Instant execution type (https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants#enum_symbol_trade_mode).

  • You have to add error processing to your code, check the return value of OrderSend or OrderSendAsync (true or false), AND the retcode of result structure. We can't help you without this retcode.
  • You also have to check the value returned by SymbolInfoDouble(...ASK), you can have an error there. Please read the documentation.
  • With Instant execution you always need to specify the entry price.
Kheops_888
19
Kheops_888  

Thank you for the advices, i will do this and if the error reapear i will tell you the code, (opportunities are rare)

Good evening.

Kheops_888
19
Kheops_888  

No new situation appeared so i can't have error code.

But i'have find the reason ;

http://img15.hostingpics.net/pics/624867gape.png

It was a gape.

The price deseapear at 10.59PM and reapear at 11.10PM

2015.01.21 23:09:51.127    Trades    '676751': failed market sell 0.10 GBPNZD [No prices]

The order was at 11.09PM

So it was in the gape.

So I understood the message [No price]

But i had a filter for test a spot ;

bool autorisationTraderPaire(string paire) export{

  MqlTradeRequest requete={0};
  requete.action=TRADE_ACTION_DEAL;
  requete.symbol=paire;
  requete.volume=0.01;
  requete.type=ORDER_TYPE_BUY;
  MqlTradeCheckResult resultat={0};
 
  return(OrderCheck(requete,resultat));
 

}

This return true instead of the gape.

So do you know if it is possible to trade in a gape ? (what i need to modificate in my code for oppening a position)

Or if not do you know how can i filter correctly this ?

Thank you very much and have good evening.



superzozo
6
superzozo  

So do you know if it is possible to trade in a gape ? (what i need to modificate in my code for oppening a position)

To add comments, please log in or register