can someone help me write the in last line of csv file

 

hi everyone

first i most say that this forum is very helpful for me

thanks for all the members

second i can use help

i wrote this code & i cant fine the way to get last line into var

ReadOrdesrs = FileOpen(Symbol() + "_data.csv",FILE_CSV|FILE_READ|FILE_WRITE,',');
while (FileIsEnding(ReadOrdesrs)==false)
{
string sDateNTime = FileReadString(ReadOrdesrs);
string sType = FileReadString(ReadOrdesrs);
string sSize = FileReadString(ReadOrdesrs);
string sSymbol = FileReadString(ReadOrdesrs);
string sLastPrice = FileReadString(ReadOrdesrs);
string sSL = FileReadString(ReadOrdesrs);
string sTP = FileReadString(ReadOrdesrs);


if (FileIsEnding(ReadOrdesrs)==true)
break;

LastDateNTime = sDateNTime;
LastType = sType;
LastSize = sSize;
LastSymbol = sSymbol;
LastPrice = sLastPrice;
LastSL = sSL;
LastTP = sTP;
}

this is the csv i'm trying to read

Time,Type,Size,Symbol,Price,SL,TP
2010.02.01 01:00,sell,0.1,EURUSD,1.22118,0,1.21000
2010.02.24 15:48,buy,0.2,EURUSD,1.22018,0,1.23450
2010.02.24 22:52,buy,0.2,EURUSD,1.231,0,1.23650
2010.04.15 04:59,sell,0.4,EURUSD,1.27996,0,1.27000
2010.05.01 08:21,buy,0.1,EURUSD,1.25225,0,1.26500
2010.05.12 12:44,buy,0.1,EURUSD,1.20485,0,1.21000
2010.05.15 10:41,sell,0.4,EURUSD,1.2049,0,1.20000
2010.05.15 03:37,sell,0.6,EURUSD,1.27158,0,1.25000
2010.05.18 21:51,sell,0.6,EURUSD,1.21118,0,1.20000
2010.05.22 09:12,buy,0.2,EURUSD,1.2195,0,0.12300

if someone can tel me what code is missing or no good i'ill very thankful

how can write (change) in last line a stop loss after the file is made

thanks a lot

jol

 

Don't forget to put FileClose(ReadOrdesrs) at the end.

 

You need to remove this line:

if (FileIsEnding(ReadOrdesrs)==true) break;

It causes the loop to exit BEFORE updating the 'Last' variables with the contents of the last line. It's not needed anyway, since the while loop checks exactly the same criterion...


Please note for next time: