Features of the mql5 language, subtleties and tricks - page 206

 
Vladimir Pastushak:
How do I know the Take Profit and Stop Loss of a position in the history?

DEAL_OUT contains these fields.

 
fxsaber:

DEAL_OUT contains these fields.

DEAL_ENTRY_OUT? how exactly do I get these fields?

 
fxsaber:

We have an open position with zero SL and TP, then we modify the position and SL !=0 and TP !=0, then we close the position manually, no matter with an owl, but not at take or stop price....

How do we find these levels of SL and TP ? No way at the moment, and then prove to someone that the position was closed differently ...

It would be logical to see an order/modification of a position and a trade which resulted in a changed position with the specified SL and TP...

 
Vladimir Pastushak:

We have an open position with zero SL and TP, then we modify the position and SL !=0 and TP !=0, then we close the position manually, no matter with an owl, but not at take or stop price....

How do I find these levels of SL and TP ? No way at the moment, and then prove to someone that the position was closed differently ...

Screenshot from terminal or investment access.

It would be logical to see an order/modification of a position and a trade which resulted in a changed position with the specified SL and TP...

DEAL_SL/DEAL_TP fields.

 
fxsaber:

Screenshot from Terminal or investment access.

DEAL_SL/DEAL_TP fields.

The positions are closed by the Expert Advisor and they have SL and TP, but it is not possible to get SL and TP in the history for trades and orders

DEAL_ENTRY_OUT says that deal was done by EA.

I have already checked everything across and across, both orders and deals, there is no way to get SL and TP levels of a position if the position was closed otherwise...

 
Vladimir Pastushak:

I have already checked everything, both orders and trades, there is no way to know the SL and TP levels of a position if the position was closed otherwise...

DEAL_SL/DEAL_TP is a future solution.

 

I don't know if it was or wasn't:

Structures and classes can contain themselves as a static field. This can be used when a class contains static fields - pointers to objects that need to be deleted when the program ends. Example:

class A
  {
   int               a;
  };

class CRecurs
  {
public:
   int               a;
   static A *        element;
   static CRecurs    s;
                     CRecurs(void) { Print(__FUNCSIG__, " ", EnumToString(CheckPointer(element))); }
                    ~CRecurs(void) { delete element; Print(__FUNCSIG__, " ", EnumToString(CheckPointer(element)));  }
  };
static A* CRecurs::element = new A;
static CRecurs CRecurs::s;

void OnStart() {}

Result:

CRecurs::CRecurs() POINTER_DYNAMIC
CRecurs::~CRecurs() POINTER_INVALID

(CRecurs can be declared as struct with the same result).

You can also create a static method that returns a reference to its own class (i.e. this static field).

 
mktr8591:

I don't know if it was or wasn't:

Structures and classes can contain themselves as a static field. This can be used when a class contains static fields - pointers to objects that need to be deleted when the program ends. Example:

Result:

(CRecurs can be declared as struct with the same result).

You can also create a static method that returns a reference to its own class (i.e. this static field).

Static fields/methods differ from global (::) only in scope.

 
fxsaber:

Static fields/methods differ from global (::) only in scope.

Yes.


Life example - in Virtual library VIRTUAL class contains static const VIRTUAL_DELETE VirtualDelete;

It can be replaced by static const VIRTUAL static_Virtual;

(and of course move the destructor to VIRTUAL) .