Download MetaTrader 5

What's up with DEAL_ENTRY_* ?

To add comments, please log in or register
S.L
35
S.L  


Need know when a deal is done, if: (1) it created/scaled in, or (2) closed/scaled out, or (3) reversed position.

As I understand it DEAL_ENTRY_IN would indicate if (1); DEAL_ENTRY_OUT would indicate if (2); and DEAL_ENTRY_INOUT if (3).

However, no matter if I open a position, close, scale, or reverse - always only DEAL_ENTRY_IN is indicated (terminal build 756, @Alpari): 

void OnTradeTransaction(const MqlTradeTransaction& trans,

                        const MqlTradeRequest& request,

                        const MqlTradeResult& result)

{

    if (trans.type == TRADE_TRANSACTION_DEAL_ADD)

    {

        if (HistoryDealGetInteger(trans.deal, DEAL_ENTRY) == DEAL_ENTRY_IN)

            Print("DEAL_ENTRY_IN");

        else if (HistoryDealGetInteger(trans.deal, DEAL_ENTRY) == DEAL_ENTRY_OUT)

            Print("DEAL_ENTRY_OUT");

        else if (HistoryDealGetInteger(trans.deal, DEAL_ENTRY) == DEAL_ENTRY_INOUT)

            Print("DEAL_ENTRY_INOUT");

    }

}
Simon Gniadkowski
Moderator
18021
Simon Gniadkowski  
S.L:


Need know when a deal is done, if: (1) it created/scaled in, or (2) closed/scaled out, or (3) reversed position.

As I understand it DEAL_ENTRY_IN would indicate if (1); DEAL_ENTRY_OUT would indicate if (2); and DEAL_ENTRY_INOUT if (3).

However, no matter if I open a position, close, scale, or reverse - always only DEAL_ENTRY_IN is indicated (terminal build 756, @Alpari): 

Is your ticket number correct ? 

S.L
35
S.L  
RaptorUK:

Is your ticket number correct ? 

Well, when a deal happens OnTradeTransaction is invoked, with the corresponding MqlTradeTransaction structure holding the deal ticket (see code above).

Querying HistoryDealGetInteger with DEAL_ENTRY and that deal's ticket should in theory yield the deal's effect on the position..

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Deal Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Deal Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Deal Properties - Documentation on MQL5
Simon Gniadkowski
Moderator
18021
Simon Gniadkowski  
S.L:

Well, when a deal happens OnTradeTransaction is invoked, with the corresponding MqlTradeTransaction structure holding the deal ticket (see code above).

Querying HistoryDealGetInteger with DEAL_ENTRY and that deal's ticket should in theory yield the deal's effect on the position..

Yes, I read the documentation, but is your ticket number correct ?  if you . . .

Print("Ticket number: ", trans.deal);

  . .  what do you get ?  do you get the correct ticket number ?

S.L
35
S.L  
RaptorUK:

  . .  what do you get ?  do you get the correct ticket number ?

I open a position manually (from terminal->new order, mkt), get one ticket; then I close this position by opposit trade in the same way, and get another (different) ticket. So all correct. But both times I get DEAL_ENTRY_IN.

All I want to know is how a deal (that triggered OnTradeTransaction) changed related position.

According to docs DEAL_ENTRY_IN be indicative of opening or increasing a position; while DEAL_ENTRY_OUT be indicative of closing/decreasing a position etc., but so far no luck.

Simon Gniadkowski
Moderator
18021
Simon Gniadkowski  
S.L:

I open a position manually (from terminal->new order, mkt), get one ticket; then I close this position by opposit trade in the same way, and get another (different) ticket. So all correct. But both times I get DEAL_ENTRY_IN.

All I want to know is how a deal (that triggered OnTradeTransaction) changed related position.

According to docs DEAL_ENTRY_IN be indicative of opening or increasing a position; while DEAL_ENTRY_OUT be indicative of closing/decreasing a position etc., but so far no luck.

OK,  I'll try one last time . . . .

 

What do yo get printed when you Print the ticket number you are using ?  is it the correct ticket number ? 

S.L
35
S.L  
RaptorUK:

OK,  I'll try one last time . . . .

 

What do yo get printed when you Print the ticket number you are using ?  is it the correct ticket number ? 

 Yes, numbers are correct.
Alain Verleyen
Moderator
32756
Alain Verleyen  

I have tested it. This is a bug. Effectively HistoryDealGetInteger(trans.deal, DEAL_ENTRY) always return DEAL_ENTRY_IN when you open AND when you close a trade.

You have to fill a request to Service Desk.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Deal Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Deal Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Deal Properties - Documentation on MQL5
S.L
35
S.L  
angevoyageur:

I have tested it. This is a bug. Effectively HistoryDealGetInteger(trans.deal, DEAL_ENTRY) always return DEAL_ENTRY_IN when you open AND when you close a trade.

You have to fill a request to Service Desk.

Seems so.

Also my particular treminal build (756) seems old, but did/does not offer to update..

Anyway, how do I file a request?

 

Alain Verleyen
Moderator
32756
Alain Verleyen  
S.L:

Seems so.

Also my particular treminal build (756) seems old, but did/does not offer to update..

Anyway, how do I file a request?

 

I use build 773.

For a request, goto to your profile, then Service Desk.

S.L
35
S.L  
angevoyageur:

I use build 773.

For a request, goto to your profile, then Service Desk.

Thanks. Have done so.

12
To add comments, please log in or register