I'm trying to write a snippet that checks if a new trade just closed, and if that's true it will export some values to an csv.
My code looks like this:
My code looks like this:
Inserted Code
datetime current=0;
Inserted Code
[left]total = OrdersTotal(); [left]if(total > 0) current = CurTime(); if(current != CurTime()) { int f = FileOpen(Symbol()+ATRthreshold+".csv", FILE_CSV | FILE_WRITE | FILE_READ,','); string sDate = TimeToStr(iTime(NULL,0,0),TIME_DATE); sDate = StringSetChar(sDate,4,'/'); sDate = StringSetChar(sDate,7,'/'); FileSeek(f, 0, SEEK_END); FileWrite(f,sDate, TimeToStr(iTime(NULL,0,0),TIME_MINUTES), iClose(NULL,0,0), iVolume(NULL,0,0)); FileClose(f); }[/left] [/left]
I tried some different sulotions, both found here on the forum and at Meataqoutes homepage, but i can't get anyone to work properly. My own idea is the set a variabel with the date if a position is open (orderstotal > 0 ) and compare that to the current time ( if a position isn't open, the variabel will have an old value an thereby is not equal to CurrentTime() ).
Instead, i get the ea to write to the file every volume-change when an position is open.
What have i missed out?
And, another question - is it possible to change "," in a csv export to ";"?