Flagging open orders by comment

 

Hi,

Let's say I have 6 pending orders, tagged with a comment. At a certain point I want to check which ones have been triggered by reading the comment on the positions. The ones which are triggered I want to flag off.

I wrote a small function which runs through all open positions, reads the comment and flags the boolean variables to false... or that's the purpose.

Below script, only flags the first variable to False (while three are actually open positions) :

what do i do wrong?

void FlagOpenPositions() {

   for(int i=PositionsTotal()-1; i>=0; i--)
      if(m_position.SelectByIndex(i))
         if(m_position.Comment()=="buyorder1")
            flagLong1plus = false;
         else if(m_position.Comment()=="buyorder2")
            flagLong1plus = false;
         else if(m_position.Comment()=="buyorder3")
            flagLong1plus = false;
         else if(m_position.Comment()=="buyorder4")
            flagLong1plus = false;
         else if(m_position.Comment()=="buyorder5")
            flagLong1plus = false;
         else if(m_position.Comment()=="buyorder6")
            flagLong1plus = false;
}

Thanks for any tips or help

 
         else if(m_position.Comment()=="buyorder2")
            flagLong1plus = false;
         else if(m_position.Comment()=="buyorder3")
            flagLong1plus = false;

?????

 

ok this is stupid, i forgot to change the numbers.

sometimes you so busy that you don't see it.

thanks!

Reason: