CDealInfo.TypeDescription() does not "Get the deal type as a string". (from documentation)

 

The string produces by CDealInfo.TypeDescription()  is not a string representation of ENUM_DEAL_TYPE identifiers.

For example, a CDealInfo.DealType = 0 is DEAL_TYPE_BUY in ENUM_DEAL_TYPE,
but for CDealInfo.DealType = 0, CDealInfo.TypeDescription() returns the string 
"Buy type" (length: 8) in the Watch window.

The stings returned by CDealInfo.TypeDescription() do not agree with the identifiers or description in ENUM_DEAL_TYPE and is not the same as EnumToString(dealType).
CDealInfo.TypeDescription() does not "Get the deal type as a string". 

For example, the results of the following code:

      CDealInfo cDealInfo.SelectByIndex(i);
      ENUM_DEAL_TYPE  dealType = cDealInfo.DealType();
      string str = EnumToString(dealType);
      string typeDescription = cDealInfo.TypeDescription();

when cDealInfo.DealType() = DEAL_TYPE_BALANCE (2), str = "DEAL_TYPE_BALANCE" (length: 17),
but cDealInfo.TypeDescription() returns "Balance type" (length: 12)
WHY isn't the string returned from  cDealInfo.TypeDescription() always the same as EnumToString(dealType) ???

Why doesn't CDealInfo.TypeDescription() produce string representations that correspond to ENUM_DEAL_TYPE

 

Maybe you should have a look at the source code as previously instructed:

//+------------------------------------------------------------------+
//| Get the property value "DEAL_TYPE" as string                     |
//+------------------------------------------------------------------+
string CDealInfo::TypeDescription(void) const
  {
   string str;
//---
   switch(DealType())
     {
      case DEAL_TYPE_BUY:
         str="Buy type";
         break;
      case DEAL_TYPE_SELL:
         str="Sell type";
         break;
      case DEAL_TYPE_BALANCE:
         str="Balance type";
         break;
      case DEAL_TYPE_CREDIT:
         str="Credit type";
         break;
      case DEAL_TYPE_CHARGE:
         str="Charge type";
         break;
      case DEAL_TYPE_CORRECTION:
         str="Correction type";
         break;
      case DEAL_TYPE_BONUS:
         str="Bonus type";
         break;
      case DEAL_TYPE_COMMISSION:
         str="Commission type";
         break;
      case DEAL_TYPE_COMMISSION_DAILY:
         str="Daily Commission type";
         break;
      case DEAL_TYPE_COMMISSION_MONTHLY:
         str="Monthly Commission type";
         break;
      case DEAL_TYPE_COMMISSION_AGENT_DAILY:
         str="Daily Agent Commission type";
         break;
      case DEAL_TYPE_COMMISSION_AGENT_MONTHLY:
         str="Monthly Agent Commission type";
         break;
      case DEAL_TYPE_INTEREST:
         str="Interest Rate type";
         break;
      case DEAL_TYPE_BUY_CANCELED:
         str="Canceled Buy type";
         break;
      case DEAL_TYPE_SELL_CANCELED:
         str="Canceled Sell type";
         break;
      default:
         str="Unknown type";
     }
//---
   return(str);
  }
 

And please stop opening so many separate topics! Reuse your existing topics to continue your queries.

Or better still, do some actual research before asking questions that can be easily obtained by reading the documentation or looking at example code.

 
Fernando Carreiro #:

And please stop opening so many separate topics! Reuse your existing topics to continue your queries.

Or better still, do some actual research before asking questions that can be easily obtained by reading the documentation or looking at example code.

You didn't answer the question asked:

WHY isn't the string returned from  cDealInfo.TypeDescription() always the same as EnumToString(dealType) ???


I thought the point of these forums is to also discuss what we find strange or could be done better. Discussions are encouraged.

I did look at the documentation before I posted and found a workaround for the issue, but still others can learn for where we find ourselves tripped up by MQL5.

If not in these forums, where should I report suspected Bugs and requests for improvement?

How does the MQL5 team receive feature requests?

 
Don Baechtel #WHY isn't the string returned from  cDealInfo.TypeDescription() always the same as EnumToString(dealType) ???

Already answered in post #1.

Don Baechtel #If not in these forums, where should I report suspected Bugs and requests for improvement?

You didn't report a bug. You "reported" your own misconceptions, which was clarified by my answer in post #1.

 
Fernando Carreiro #:
WHY isn't the string returned from  cDealInfo.TypeDescription() always the same as EnumToString(dealType) ???

You answered the What, not the Why?

Improved question: WHY does cDealInfo.TypeDescription() always return a different string than EnumToString(dealType) ???
A reasonable person would expect them to have the same results.

The documentation states CDealInfo.TypeDescription() "Get the deal type as a string".  It does not.
That should be considered a Bug in either MQL5 code or the MQL5 documentation. No?

Would it not be an improvement to MQL5 if the results were the same and not something unexpected where  the MQL5 code must be inspected?

 
Don Baechtel #A reasonable person would expect them to have the same results.

And why would a reasonable person expect that?

Does the documentation state such a fact?

Don Baechtel #The documentation states CDealInfo.TypeDescription() "Get the deal type as a string".  It does not.

Does it state that it will return the code enumeration as a string, or does it simply state "Get the deal type as a string"?

You are just projecting your misconceived interpretation and complaining that it is not what you "wanted".

There can be many possible interpretations, to each its own, but it is what it is—a string value for the deal type!