Is there any code in MQL5 to set global non-trading? even in strategy backtesting.

 

Is there any code in MQL5 to set global non-trading, even during strategy backtesting.

Including passive transactions such as triggering take profit, stop loss and pending orders.

 

I want to control passive transactions such as triggering take profit, stop loss. 

I know it can do that by setting up functions by myself.

But I wonder if MT5 has a direct way to control it. 

 
Yu Zhang # :

I want to control  passive transactions such as triggering  take profit , stop loss. 

I know it can do that by setting up functions by myself.

But I wonder if MT5 has a direct way to control it. 

In MQL5, you can very easily distinguish between a deal that occurred as a result: Stop Loss or Take Profit. You can distinguish between "entry into the market" and "out of the market" deal and much more.

Trades need to be tracked in ' OnTradeTransaction '. Types of transactions that can be tracked:  Deal Properties


Example:

Forum on trading, automated trading systems and testing trading strategies

Delete all pending orders for ALL SYMBOLS once one pending is Filled

Vladimir Karputov, 2022.03.08 17:09

Delete pending orders rules

Principle of operation

The EA tracks the entry of positions (if ' Catch 'IN' Deals ' is set to ' true ') or the closing of positions (if ' Catch 'OUT' Deals ' is set to ' true '). It does not matter what symbol and what Magic was the deal. As soon as the necessary deal is caught, all pending orders (for all symbols and for all Magic) will be deleted.


Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Deal Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Deal Properties
  • www.mql5.com
Deal Properties - Trade Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Vladimir Karputov #:

In MQL5, you can very easily distinguish between a deal that occurred as a result: Stop Loss or Take Profit. You can distinguish between "entry into the market" and "out of the market" deal and much more.

Trades need to be tracked in ' OnTradeTransaction '. Types of transactions that can be tracked:  Deal Properties


Example:


Thanks, I know trades can be tracked in ' OnTradeTransaction '.

I was wondering if we could pause it.

For example, I don't remove the stoploss in advance.  If the price triggers my stoploss order,  It would normally trigger a closed trade. But I hope it doesn't make stoploss trades.  

Is there any code that can do this without removing the stop loss ? 


 
Yu Zhang #: Thanks, I know trades can be tracked in ' OnTradeTransaction '. I was wondering if we could pause it. For example, I don't remove the stoploss in advance.  If the price triggers my stoploss order,  It would normally trigger a closed trade. But I hope it doesn't make stoploss trades. Is there any code that can do this without removing the stop loss ? 

No, there is no such functionality in MetaTrader. You would have to temporarily remove stops from positions and delete pending orders so as to prevent triggering anything.
 
Fernando Carreiro #:
No, there is no such functionality in MetaTrader. You would have to temporarily remove stops from positions and delete pending orders so as to prevent triggering anything.

Thank you. I can't find it in the documentation either.

Reason: