我把我的EA所做的所有交易保存到一个CSV文件中。当一个交易被EA关闭时,我必须在文件中的特定行的末尾添加字符串“账面利润”。例如:下面是在交易打开时保存在文件中的行“Buy GBPJPY 146.28 145.15”,我想在上面行的末尾添加字符串“Book Profit”并将其保存到文件中。保存后该行应该看起来像“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");
}
}
此代码只是覆盖文件,文件不可读
2条答案
按热度按时间7qhs6swi1#
在写入文件之前,首先查找文件的结尾:
ilmyapht2#
使用下列函数搭配您的四个参数(Buy、GBPJPY、146.28、145.15):