prevent boolean variable state reset when leaving order selection cycle

 

Good day,

bool check == False;

//---- ORDER SELECTION

for(n = OrdersTotal()-1; n >= 0 ; n--)
    if (OrderSelect(n, SELECT_BY_POS) && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
    {
       if (A > B && check == False)
       {
          check = True;
          Print(check);
       }
    }

because when leaved cycle it returns variable false again. How it is possible to keeping value true after changed first time so that Print(check); is executing only one time only. Thank you for help.

 
Make it static . . .
 
RaptorUK:
Make it static . . .

Good. But then variable always is True. How I must do when I want to variable set False again when no order is opened?
 
if ( OrdersTotal()==0 ){ check=false; }
 
ubzen:
if ( OrdersTotal()==0 ){ check=false; }

Allah! Thank you many time! This is logical! I am apologize! I didn't have thinked! Thank you, thank you!