Cannot delete pending order MQL5/ MT5 - page 2

 
figurelli:

For sure, this is just risk advices about the use of such codes, principally for the BM&FBovespa pilot project, that I suppose is the main idea of Marcelo, and that this code can manage his real accounts.

Unfortunately, for stock exchanges in general, and this is my opinion, MT5 is not so secure and portable yet as for Forex (despite we still have some minor problems at Forex, several of them discussed at this Forum).

In this sense, and if you want and have your time to contribute and discuss about it, I created a topic in the Portuguese area and you are welcome there (https://www.mql5.com/pt/forum/23409) to contribute with your critics and ideas (even in English).

Anyway, if possible, I would like to know your opinion about the use of such codes at BM&FBovespa, as maybe I'm wrong and there are no risks here.

Thank you.

Sorry but I still don't see which risk you are talking about, as we are talking about deleting pending orders. So I don't say you are wrong or not, I simply ask to understand.

Thank you for your invitation to Portuguese forum, I certainly will take a look at this topic.

 
angevoyageur:

Sorry but I still don't see which risk you are talking about, as we are talking about deleting pending orders. So I don't say you are wrong or not, I simply ask to understand.

Thank you for your invitation to Portuguese forum, I certainly will take a look at this topic.

You just told what I'm talking about, in other words, note that any code fail/error deleting pending orders can lead to critical errors too, since you can delete what you don't want (another symbols, for instance), or worst, send wrong orders to the market.

 
Malacarne:
Please take a look at this post. It's a kind of "best practice" to check not only the return codes from the server, but also the boolean value you get from your OrderDelete() function (in case you actually uses it).
Done. Thank you.
 
figurelli:

Hi Marcelo, note that the first code you post will filter all orders just by symbol name, so this is very risky, in my opinion, principally for BM&FBovespa.

The second code is not enough too, since don't test any symbol and if you just need do delete pending orders this is not right.

The big problem here is that several of this details are, in my opinion, very risk to BM&FBovespa, and not so critical to Forex market, but most of MQL5 site examples are regarding Forex.

1.This code belong to the EA we are working on. It will work with only one symbol (WINM14 or its variances). Still have a problem ?

2. Agree ... working on that.

3. Can y be more specific ?

 
angevoyageur:

Do you mean a stop order ? (BUY_STOP or SELL_STOP). With MT5, a stoploss is not a pending order but is linked to an other order (market or pending).

There are several reasons why this code doesn't delete your order, as said by Malacarne and Figurelli, you always have to check the return code, whatever method you are using to send trade request.

OrderGetTicket() already select your order, you don't need to use OrderSelect() too.

I got your point. Thank you ! I will work on that !
 
angevoyageur:

Some fields are not needed to delete a pending order. You don't print the error when OrderSend return false :

P.S: I don't think you can get a return 1008 (TRADE_RETCODE_PLACED) when deleting a pending order. Not sure though, can someone confirm ?
Fixed. Thank you !
 
YouTrade:

1.This code belong to the EA we are working on. It will work with only one symbol (WINM14 or its variances). Still have a problem ?

2. Agree ... working on that.

3. Can y be more specific ?

Hi Marcelo, for sure, take care about any OrderSend() you are introducing, like these ones, principally on BM&FBovespa, or any other exchange market where you have to connect MT5 server to an OMS.

It would be necessary check all changes to identify new potential problems. Note that most of the mistakes that was pointed out to you are because you took a buy/sell order to adapt to a pending order, what is very risky, since even just a pending order can create several problems, as I stated before. 

For instance, a pending order can emulate a StopLoss (SL), to protect an account. There are several strategies that do it. If you commit a mistake, you lose your virtual SL. And without SL ... you know the risk.

So, beware even in the case you are just sending orders to change the SL/TP levels.

Actually, the best way I can see to start trading on real accounts (talking about BM&FBovespa, but maybe for Forex too), after backtesting and demo account tests, is start with low balance (<=$500) and same low margin, double checked by risk team of the broker you use. Also, check if your broker risk team will really avoid any margin call in real time. 

This because not just your client EA and platform can fail, but any other architecture and server components.

And because security is a process, not a solution to uncertainty, anything you create now that you consider safe can be unsafe tomorrow.

You are welcome to discuss such risks at Portuguese topic https://www.mql5.com/pt/forum/23409 too.

Um checklist dos riscos dos robôs antes de operar em conta real
Um checklist dos riscos dos robôs antes de operar em conta real
  • www.mql5.com
Existe um modo de pânico no Expert Advisor para administrar situações de risco de perda de capital por falhas ou erros dos algoritmos?
 
Well, I think he simply wanted to delete a pending order... It's interesting how this "security" debate is taking place on this topic...
 
Malacarne:
Well, I think he simply wanted to delete a pending order... It's interesting how this "security" debate is taking place on this topic...

Probably Marcelo needs to do it safely, and I'm just answering questions and sharing my vision about it.

Anyway you are free to think differently, mainly if you see no risks about deleting pending orders and/or Marcelo coding questions.

Reason: