Dividing open positions into groups - page 2

 
Nikolay Kositsin:

Such code is too individual to exist in ready-made form. We will write a structure with ready comments for all variants of necessary attributes for positions and orders, and an Expert Advisor which analyzes positions and orders and changes those comments. Such things are either written independently, or commissioned from a freelancer.

Of course I agree with you, but I'm not looking for "off-the-shelf...", I'm not begging and I'm not ordering. I offer to share my knowledge, which can be used (and will be used myself) to implement an interesting, in my opinion, idea. I will post the executed code here too, any participation is welcome.

 
Sergey Voytsekhovsky:

Of course I agree with you, but I'm not looking for "off-the-shelf...", I'm not begging and I'm not ordering. I offer to share my knowledge, which can be applied (and will be applied myself) to implement an interesting, in my opinion, idea. I'll post what I've done here too, any participation is welcome.

Look in my articles. It's already done there. In which one - I do not remember. But you can read it in the speeches. Made in two ways. The second left as a working version - storage of user IDs in magik.
 
Artyom Trishkin:
Have a look in my articles. It is already done there. In which one - I do not remember. But you can read it in the speeches. Made in two ways. The second left as a working version - storage of user IDs in magik.

Thanks, very much looking at your code, use it often, thanks for your hard work, but you have so many works that I haven't found on this topic yet. I'll try searching with the hashtag "custom identifiers", thanks for the tip.

 
Sergey Voytsekhovsky:

Thanks, very much looking at your code, use it often, thanks for your hard work, but you have so many works that I haven't found on this topic yet. I'll try searching with the hashtag "custom identifiers", thanks for the tip.

https://www.mql5.com/ru/articles/7394
 
Artyom Trishkin:
https://www.mql5.com/ru/articles/7394

Thank you, I've gone into the text :-()

 
Grigori.S.B:

I would not advise using the comment field. It is of course the easiest way, but also the most unreliable, as this field can be changed by the DC at any time.

Well, the tracking system is designed to change the comment at any time if it does not correspond to the state of position or order. So for visual observation it does not change the case.
 
Sergey Voytsekhovsky:

I do not understand your question

I mean this https://www.mql5.com/ru/forum/48768

комментарий к ордеру
комментарий к ордеру
  • 2003.03.17
  • www.mql5.com
Общее обсуждение: комментарий к ордеру
 

Good evening.

I did a quick search of the recommended links and came to the conclusion that for the time being I shouldn't make it too complicated.

I'll try to make do with a two-dimensional array for now. I created it and wrote data into it. I decided to check whether it worked correctly, and it turned out to be wrong!

//+------------------------------------------------------------------+
int Array_Creating_Caste_Positions()
{
   int n = 0;
   int size = PositionsTotal();
   for(int i=0; i<size; i++)
   {
      if(m_position.SelectByIndex(i))
      {
         int profit = (m_position.Profit()+m_position.Commission()+m_position.Swap())>0?1:-1;
         int type   = m_position.Type()==POSITION_TYPE_BUY?0:1;
         ArrayResize(arr_position,size,2);
         
         arr_position[i][0] = m_position.Identifier();
         arr_position[i][1] = m_position.Magic();
         arr_position[i][2] = profit;
         arr_position[i][3] = type;
         arr_position[i][4] = -1; //N_Caste (-1 = нет данных)
         n++;
      }
   }
return(n);
}
//+------------------------------------------------------------------+

To check temporarily created variables and put them in the Comment, it does not work correctly!

      int N = Array_Creating_Caste_Positions();
      
      int profit_Plus  = 0;
      int profit_Minus = 0;
      int N_Buy        = 0;
      int N_Sell       = 0;
      int size = PositionsTotal();
      
      for(int i=0; i<size; i++)
      {
         if(arr_position[i][2] > 0) profit_Plus++;
            else profit_Minus++ ;
         if(arr_position[i][3] < 1) N_Buy++;
            else N_Sell++ ;
      }
//+--- 
      if(InpCommentLog){
         Comment("Выводим данные \n"
         "всего записей в массиве ",N,"\n"
         "-----------------------: ",0,"\n"
         "profit_Plus:  ",profit_Plus,"\n"
         "profit_Minus: ",profit_Minus,"\n"
         "-----------------------: ",0,"\n"
         "N_Buy: ",N_Buy,"\n"
         "N_Sell: ",N_Sell,"\n"
         );}
//+--- 

Can anyone suggest - where I messed up,,?

Files:
Sower_1_3.mq5  17 kb
 

If you run it in the tester, it appears that all positions (open) are profitable and all of them are purchases

profit_Plus == N_Buy == N  чего в принципе не должно быть.
 

the comment in the top left corner

I don't know how to make it large, sorry.