Comparing open Positions one Selected by Index other by Ticket

 
   for(int i=(int)MathRound(PositionsTotal()) ; i>=0; i--)
   {
      if(posyInfo.SelectByIndex(i))      
      {
         if(posyInfo.Magic()==maggi && posyInfo.Symbol()==paar)
         {

How can i compare inside this loop the actual selected PositionInfo(select by Index) with another Positioninfo(set by Ticket).

So that for example

if(posyInfo.PriceOpen()>=posyInfo.PriceOpen(ticket){ticket=posyInfo.Ticket}

Thanks a lot in advance.

 
Pr02type:

for(int i=(int)MathRound(PositionsTotal()

Why are you taking an int, converting it to a double, rounding it (which does nothing), and then converting it back to an int?

 
William Roeder:

Why are you taking an int, converting it to a double, rounding it (which does nothing), and then converting it back to an int?

Hello William,


thanks for your response. Indeed that is redundant. Changed the var i to an uint. Thanks for that hint.

I thought about creating a separate Function like this.

double posDat(ENUM_POSITION_PROPERTY_DOUBLE attribute, ulong ticket)
{
   if(PositionSelectByTicket(ticket)){return(PositionGetDouble(attribute));}
}
return(0);}

Would that work. Or is there any other more elegant way for that comparison?