Prevent MT5/MT4 from sending orders

 

Hi everyone, 

Here is the problem I am trying to solve I did not find materials for it on MQL5 yet, so I'm looking for your help. Is there a way to prevent any new orders from reaching out to the trading servers? In other words, I need to capture the event of sending order (manual, copy trade, or from EA) from the terminal and cancel it before being sent to the server. 

I did implement a code when an order is set to simply to delete or close, but I am paying the commission, and I want to prevent this.

Thanks for your help.

 
Haidar, Lionel Haj Ali: Here is the problem I am trying to solve I did not find materials for it on MQL5 yet, so I'm looking for your help. Is there a way to prevent any new orders from reaching out to the trading servers? In other words, I need to capture the event of sending order (manual, copy trade, or from EA) from the terminal and cancel it before being sent to the server. I did implement a code when an order is set to simply to delete or close, but I am paying the commission, and I want to prevent this.

Why? Explain the reason in more detail.

This seems like an X/Y problem. It may be easier to find a solution to the original issue instead of trying to block MetaTrader.

 
Fernando Carreiro #:

Why? Explain the reason in more detail.

This seems like an X/Y problem. It may be easier to find a solution to the original issue instead of trying to block MetaTrader.

Hi Fernando, 

If I ask myself what is the root cause and why I need this?  Because of the "lack of discipline" of a trader that I am trying to help him by creating a specific EA. The best solution is to ask him to learn discipline :D, it would be the best advice for him.

However, I was curious to know if there is some way to do it in mql. At this stage, I can still offer him the first scenario below, but asking if I could implement scenario two would be better (eliminate commission cost)

SCENARIO ONE:

Implemented Code


SCENARIO 2

Prevent the trade


Thanks for your always help. 

 
Haidar, Lionel Haj Ali #: If I ask myself what is the root cause and why I need this?  Because of the "lack of discipline" of a trader that I am trying to help him by creating a specific EA. The best solution is to ask him to learn discipline :D, it would be the best advice for him. However, I was curious to know if there is some way to do it in mql. At this stage, I can still offer him the first scenario below, but asking if I could implement scenario two would be better (eliminate commission cost)

There is no way to block trading on MetaTrader by using an MQL program.

If the problem is trader discipline, then maybe a possible workaround is to have them trade via an trading panel/assistant EA that would do the necessary checks before placement of the order, but that will still not prevent the trader from using the terminal's built-in trading operations.

Reason: