Manual transactions or by expert

 

Hi

Is there a way to determine which trades were taken with expert and which were entered manually in the history of Metatrader (4 or 5)?

 

Normally an EA provides its trades with its individual MagicNumber while manual trades have a MagicNumber of 0: https://www.mql5.com/en/docs/constants/structures/mqltraderequest

magic

Expert Advisor ID. It allows organizing analytical processing of trade orders. Each Expert Advisor can set its own unique ID when sending a trade request.


Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Structure
Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Structure
  • www.mql5.com
Trade Request Structure - Data Structures - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Seyedbehrang Mousavi: Is there a way to determine which trades were taken with expert and which were entered manually in the history of Metatrader (4 or 5)?

Yes! Just hover your mouse over the trade and a tooltip will pop up, indicating the type of trade.


 
Seyedbehrang Mousavi:

Hi

Is there a way to determine which trades were taken with expert and which were entered manually in the history of Metatrader (4 or 5)?

In the "Deal" structure there is a field called "reason" (ENUM_DEAL_REASON) that can be used to find out whether it was manual or automatic, regardless of the magic number.
 

In MQL5 code ...

... evaluate the reason for order placement (  ENUM_ORDER_REASON ...

ORDER_REASON_CLIENT

The order was placed from a desktop terminal

ORDER_REASON_MOBILE

The order was placed from a mobile application

ORDER_REASON_WEB

The order was placed from a web platform

ORDER_REASON_EXPERT

The order was placed from an MQL5-program, i.e. by an Expert Advisor or a script

... evaluate the reason for deal execution ( ENUM_DEAL_REASON ...

DEAL_REASON_CLIENT

The deal was executed as a result of activation of an order placed from a desktop terminal

DEAL_REASON_MOBILE

The deal was executed as a result of activation of an order placed from a mobile application

DEAL_REASON_WEB

The deal was executed as a result of activation of an order placed from the web platform

DEAL_REASON_EXPERT

The deal was executed as a result of activation of an order placed from an MQL5 program, i.e. an Expert Advisor or a script

 

In MQL4 code ...

It is only partially possible by looking at the magic number to see if it is non-zero (placed by an EA).

If it is a zero magic number, then it will remain unclear, but in most cases it will be manual.

OrderMagicNumber

Returns an identifying (magic) number of the currently selected order

OrderMagicNumber - Trade Functions - MQL4 Reference
OrderMagicNumber - Trade Functions - MQL4 Reference
  • docs.mql4.com
OrderMagicNumber - Trade Functions - MQL4 Reference
Reason: