Using OrderSelect() to find the text that i have printed to a log file

 
{
   bool   Result;
   int    i,Pos,Error;
   int    Total=OrdersTotal();
   
   if(Total>0)
   {for(i=Total-1; i>=0; i--) 
     {if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == TRUE && //what do I put in the code here to find the Print text in the log?=="my logged print text")
       {EA instruction once the OrderSelect is TRUE;}
       
//-----------------------
       if(Result!=true){Error=GetLastError();Print("LastError = ",Error);}
        else Error=0; 
//-----------------------
       }//if
     }//for
   }//if

Perhaps a silly question, but I can't seem to find the answer:


My EA is using the Print() function to print a line of text to the log file when a specific condition is met, but leaves the Order open.  I then want to find the printed line of text using the OrderSelect() function and tell the EA to do something with that order. Please see my OrderSelect() code below and advise how to find the printed text that i am looking for (see the bit that i have called //what do I put in the code here to find the Print text in the log?=="my logged print text") :

 
FXBulldog: print a line of text to the log file when a specific condition is met, but leaves the Order open.  I then want to find the printed line of text using the OrderSelect() function
  1. Selecting an order has nothing to do with what is in the log file.
  2. Remember the ticket number. Later select by ticket and verify that it isn't already closed.
  3. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.
 
Thanks for your comment WHRoeder.  However, I am not sure how to use an EA to identify/remember a ticket number when a specific condition is met, such that I can then get the EA to retrieve the Order (if it is still open) relevant for the ticket number.  I am sure that I can code the OrderSelect() once the ticket number is known, but I do not have any idea how to tell the EA to identify/remember the ticket number.  Please would you point me in the right direction...
 
If the power fails, OS crashes, terminal or chart is accidentally closed, the next tick, the ticket variable will be lost. You will have an open order but don't know it, so the EA will never try to close it, trail SL, etc. How are you going to recover? Use a orderSelect loop no recovery, or persistent storage (GV/file) of ticket numbers required.
Reason: