Block trades EA

 

Hey guys,

I was wondering if anyone had an EA to block the user from opening trades after certain conditions.

The conditions I was thinking about were, since I only trade in 2 different intervals, to limit the number of trades I could take in these intervals. So in time interval 1, if I execute a trade, the EA would stop me from executing a second one, whether it be a market order or a pending.

Is it possible to do this in MQL5 ? I tried using GPT for it since I'm not an MQL5 scripter but the code it gave me didn't work as intended so I was wondering if anyone had thought of doing this before me, perhaps has a code ready.

Thank you for your replies in advance.

 

There is no such thing! There is no EA that can block a user from placing trades!

The most it can do is immediately close any open trades or delete pending ones, but that will absolutely incur a cost of spread, commission, etc. on open trades.

What is possible, is to have the trader use an EA Trading Panel to place trades, and then have that prevent it, but trader can still use the normal MetaTrader operations to place the trade anyway.

The solution, is for the trader to learn self-discipline!

 
Fernando Carreiro #:

There is no such thing! There is no EA that can block a user from placing trades!

The most it can do is immediately close any open trades or delete pending ones, but that will absolutely incur a cost of spread, commission, etc. on open trades.

What is possible, is to have the trader use an EA Trading Panel to place trades, and then have that prevent it, but trader can still use the normal MetaTrader operations to place the trade anyway.

The solution, is for the trader to learn self-discipline!

Thanks Fernando,

I was indeed talking about manual trading. I'm trying to find way to build up my discipline but it seems the only way is through.

Thanks for letting me know, if you have any advice perhaps to become more discipline, I'd be more than glad to hear it.

Best regards

 
Ziad Bahnass #:

Thanks Fernando,

I was indeed talking about manual trading. I'm trying to find way to build up my discipline but it seems the only way is through.

Thanks for letting me know, if you have any advice perhaps to become more discipline, I'd be more than glad to hear it.

Best regards

This section is for discussing expert advisors. If you want to "block" trading, then you should use an indicator that tells you when and when not to trade, and that is nothing relevant for an EA, because while EAs or scripts can work like indicators, they're not multi-threaded.
 
Conor Mcnamara #This section is for discussing expert advisors. If you want to "block" trading, then you should use an indicator that tells you when and when not to trade, and that is nothing relevant for an EA, because while EAs or scripts can work like indicators, they're not multi-threaded.

Not a single MQL program is multi-threaded, be it Indicators, EAs, Scripts or Services! None of them are! In fact, Indicators are even "worse" off, because they share a single thread among all Indicators for a symbol.

However, what does multi-threading have to do with anything related to the issue discussed here?

 
Fernando Carreiro #:

Not a single MQL program is multi-threaded, be it Indicators, EAs, Scripts or Services! None of them are! In fact, Indicators are even "worse" off, because they share a single thread among all Indicators for a symbol.

However, what does multi-threading have to do with anything related to issue discussed here?

I thought I read in this documentation that indicators are multi-threaded and metatrader performs their calculation in parallel, so if someone needs to calculate something with buffers, they should rather do so in an indicator (even though all the OHLC data can be retrieved in an EA or script)
 
@Conor Mcnamara #I thought I read in this documentation that indicators are multi-threaded and metatrader performs their calculation in parallel, so if someone needs to calculate something with buffers, they should rather do so in an indicator (even though all the OHLC data can be retrieved in an EA or script)

No such thing in the documentation. On the contrary ... Documentation on MQL5: MQL5 programs / Program Running

Program

Running

Note

Service

A separate thread, the number of threads for services is equal to the number of services

A looped service cannot break running of other programs

Script

A separate thread, the number of threads for scripts is equal to the number of scripts

A looped script cannot break running of other programs

Expert Advisor

A separate thread, the number of threads for Expert Advisors is equal to the number of Expert Advisors

A looped Expert Advisor cannot break running of other programs

Indicator

One thread for all indicators on a symbol. The number of threads is equal to the number of symbols with indicators

An infinite loop in one indicator will stop all other indicators on this symbol

Documentation on MQL5: MQL5 programs / Program Running
Documentation on MQL5: MQL5 programs / Program Running
  • www.mql5.com
Each script, each service and each Expert Advisor runs in its own separate thread. All indicators calculated on one symbol, even if they are...