Storing ticket number to a file

 

Can someone tel me how to properly store a ticket number to a file. The file should be able to store mulitiple tickets numbers at any one giving time.

Can you also show me then how to read the file to see if the ticket number exists in the file.

thanks in advance. Here is what i have. maysomeone will correct for me..

   if (iClose(NULL, 0, 0) >= iClose(NULL, 0, 1))
                  {
      
      int Add_ticket=1; 
              if( Add_ticket==1){
                int handle=FileOpen("mydata.txt",FILE_CSV|FILE_READ | FILE_WRITE,';');
                int f=FileWrite(handle, OrderTicket());if(f<0){Print("Write file Error_1:  ",GetLastError());}
                FileClose(handle);
                if(handle<0){Print("Write file Error_1:  ",GetLastError());}
               }
                    
                    else {
                    
                        Add_ticket=-1;
                        int handle2=FileOpen("mydata.txt",FILE_CSV|FILE_READ | FILE_WRITE,';');
                        int f2=FileWrite(handle2, OrderTicket());if(f2<0){Print("Write file Error_1:  ",GetLastError());}
                        FileClose(handle2);
                        if(handle2<0){Print("Write file Error_1:  ",GetLastError());}
               }
                    
double Vaule_1;
                
           if(OrderType()==OP_BUY || OrderType()==OP_SELL)
                 {       
           int handle2=FileOpen("mydata.txt", FILE_BIN|FILE_READ);
                               if(handle2>0)
                                      {
                           Vaule_1=FileReadInteger(handle2, LONG_VALUE );
                           FileClose(handle2);
                                 }
                if(handle2<0){Print("Read file Error_3 :  ",GetLastError());}
           
           
           
            if (Vaule_1==OrderTicket())
                  { 
             if (OrderStopLoss() < OrderOpenPrice())
 

can anyone fix this...

 
Unless your storing additional data, why bother
    for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
        OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
    &&  OrderMagicNumber() == magic.number              // my magic number, and
    &&  OrderSymbol()      == Symbol() ){               // period and symbol

will give you currently open tickets.

If your will be storing additional data, keep the data in arrays, array of order numbers, array of data, etc. at end of start you'll loop through the arrays and write the data. At init, read the file in a loop while(!FileIsEnding()){ read into arrays }

Search persistent storeage.

 
WHRoeder:
Unless your storing additional data, why bother

will give you currently open tickets.

If your will be storing additional data, keep the data in arrays, array of order numbers, array of data, etc. at end of start you'll loop through the arrays and write the data. At init, read the file in a loop while(!FileIsEnding()){ read into arrays }

Search persistent storeage.

Thats easially said. I no nothing about arrarys or how to write them properly.
Reason: