I am saving all the trades done by my EA into a CSV file. When a Trade is closed by the EA, I have to add string "Book Profit" to the end of particular line from the file. eg: Below is the line that is saved in the file while trade is open "Buy GBPJPY 146.28 145.15", I would like to add string "Book Profit" to the end of the above line and save it to the file. After saving the line should look like "Buy GBPJPY 146.28 145.15 Book Profit"
int file_handle_dtf=FileOpen("MyTrades.CSV",FILE_READ|FILE_WRITE|FILE_CSV);
if(file_handle_dtf!=INVALID_HANDLE){
while(!FileIsEnding(file_handle_dtf)){
str_size1=FileReadInteger(file_handle_dtf,INT_VALUE);
//--- read the string
str1=FileReadString(file_handle_dtf,str_size1);
strBP=StringConcatenate(str1,",Book Profit");
FileWriteString(file_handle_dtf,strBP+"\n");
}
}
This code just overwrites the file and it is not readable