Questions from a "dummy" - page 135

 
Cmu4:

I reduce the volume by counter-order, write a comment in it, but the comment stays in it, it does not "cling" to the position...

The most interesting thing is that if the order is sent with a comment in the direction of the position, it receives this comment, if against - it does not.

Maybe it's a bug?

I have looked at my EA in visualization mode and saw that sometimes the comments "stick" and sometimes they don't. Can't say anything yet (it's not critical for me). Observe some more and write to Service Desk if you find a pattern to reproduce.
 
tol64:
I looked at it in visualisation mode and saw that sometimes comments are "hooked" and sometimes not. Can't say anything yet (it's not critical for me). Observe some more and write to Service Desk if you find any pattern to the replay.

I already did. Hmm, I always get the wrong ones. And there's a hell of a thing about "excerpting" a comment. Ufff...

By the way, here's a simple function to get the comment of the last trade (only numbers in the comments) on a position, is it correct? Otherwise, maybe I'm "scraping" it wrong...

double OrderLastMy()
{HistorySelectByPosition(pos_id);
 int total=HistoryDealsTotal();
 double Comments = StringToDouble(HistoryDealGetString(total,DEAL_COMMENT));
 if (Comments!=0)
  {Print("comment = ", Comments));
   return(Comments);
  }
 else return(0);
 }
 
Cmu4:

I already did. Hmm, I always get the wrong ones. And there's a hell of a thing about "excerpting" a comment. Ufff...

By the way, here's a simple function to get the comment of the last trade (only numbers in the comments) on a position, is it correct? Or maybe I'm not "getting it right"...

double OrderLastMy()
{HistorySelectByPosition(pos_id);
 int total=HistoryDealsTotal();
 double Comments = StringToDouble(HistoryDealGetString(total,DEAL_COMMENT));
 if (Comments!=0)
  {Print("comment = ", Comments));
   return(Comments);
  }
 else return(0);
 } 

The HistoryDealGetString() function should have as first parameter the ticket of transaction, and so far you have the number of deals in history.

 
Yedelkin:

The first parameter of the HistoryDealGetString() function should be a transaction ticket, but so far you are specifying the number of transactions in the history.

I have corrected it, but it still doesn't work. Gentlemen, please advise, because I'm confused...

double OrderLastMy()
{HistorySelectByPosition(pos_id);
 int total=HistoryDealsTotal();
 int ticket = HistoryDealGetTicket(total);
 double Comments = StringToDouble(HistoryDealGetString(ticket,DEAL_COMMENT));
 if (Comments!=0)
  {Print("commentttt = ", ticket);
   return(Comments);
  }
 else return(0);
 }
 
 
 
Cmu4:

I fixed it, but it still doesn't work. Gentlemen, please advise, because I'm confused...

All right, let's move on :)

Here's the line.

int ticket = HistoryDealGetTicket(total);
does not take into account that numbering of items in lists (including numbering of deals in the deal list) starts with "0", not "1". Therefore, by specifying the value total as "transaction number in the transaction list", you are specifying a non-existent number. See example in MQL5 Reference / Trading Functions / HistoryDealGetTicket.
 
Yedelkin:

All right, let's move on :)

Here's the line

does not take into account that numbering of items in lists (including numbering of deals in the deal list) starts with "0", not "1". Therefore, by specifying the value total as the "transaction number in the transaction list", you are specifying a number that does not exist. See the example at MQL5 Reference / Trading Functions / HistoryDealGetTicket.
Thank you very much, adding -1 solved everything (I hope it did - I checked via print for now). :)
 
It's strange...
   datetime Arr[], time1;
   int t;

   t=CopyTime(_Symbol,_Period,0,1,Arr);
   time1=Arr[0];
Print(time1) doesn't print anything in this version of the code, but in this one:
   datetime Arr[], time1;

   CopyTime(_Symbol,_Period,0,1,Arr);
   time1=Arr[0];

- outputs.

Is this a bug or a feature?

 
Maybe t should be defined as datetime?
 
Cmu4:
Maybe t should be defined as datetime?

t cannot be datetime, read CopyTime help carefully:

"Return value:

Thenumber of copiedarray items or -1 in case of an error."

Intuitively, it seems as if this function's return is processed and the return value is safely assigned to the t variable... and at this point the program hangs up, as if nothing else wanted to be copied into Arr. But supposedly I thought that copying into the array must be performed first, and only then - assigning to the t variable the returned number of copied items. But here goes...
 
alph:

Hello!

I have written an EA, everything works. But i got an error at the opening line of ' request.type_filling = ORDER_FILLING_AON;'-undeclared identifer and implicit enum conversion

Can't figure out what's wrong, all EAs compiled so far with the same strings work as before.

Thanks in advance.

If you click on the ORDER_FILLING_AON link, you'll see that the name has just changed.