Hi,
I would expect the following code to write only one line to the csv file but it writes 600 lines on a 55T chart and more on a 1min chart (ES #F). The above is measured as soon as the efs is loaded and since it was run about 3 AM a new bar was never created. So, 600 lines were written just by loading the efs even though there is a counter limit of 1 iteration.
I'm testing this method so when a real time buy, sell, stop, etc signal is triggered it writes pertinent trade information into one line in the csv file.
Attached is the csv file from efs running the code below on a 55T chart of ES #F.
Any help is appreciated.
Wayne
I would expect the following code to write only one line to the csv file but it writes 600 lines on a 55T chart and more on a 1min chart (ES #F). The above is measured as soon as the efs is loaded and since it was run about 3 AM a new bar was never created. So, 600 lines were written just by loading the efs even though there is a counter limit of 1 iteration.
I'm testing this method so when a real time buy, sell, stop, etc signal is triggered it writes pertinent trade information into one line in the csv file.
Attached is the csv file from efs running the code below on a 55T chart of ES #F.
Any help is appreciated.
Wayne
PHP Code:
//http://forum.esignalcentral.com/showthread.php?s=&postid=110331#post110331
debugClear();
function preMain() {
setPriceStudy(true);
setStudyTitle("file creation test");
setShowCursorLabel(false);
}
var bInit = false;
var vToday = new Date();
var AuditTrailFile = "writetxtfiletest.txt";
var CSVFile = "writecsvfiletest.csv";
var vCounter = 0;
function main(){
if (!bInit){
}
if (getBarState()==BARSTATE_ALLBARS) return;
if (getBarState()==BARSTATE_NEWBAR){
if(vCounter <=0){
vText = (vToday.getFullYear(0)+"/"+vToday.getMonth(0)+"/"+vToday.getDate(0)+" - "+
hour(0)*100+minute(0)+":"+vToday.getSeconds(0)+
" Ask- "+getMostRecentAsk()+" Bid- "+getMostRecentBid()+" Price- "+getMostRecentTrade());
efsInternal( "fWriteAuditTrail", vText );
efsInternal( "fWriteCSVFile", vText,close(0) );
vCounter++
debugPrintln(vCounter);
}
}
}
function fWriteAuditTrail(vText) {
var f = new File(AuditTrailFile);
f.open("at");
f.write(vText+"\n");
f.close();
}
function fWriteCSVFile(vText, Amount) {
var f = new File(CSVFile);
f.open("at");
f.write(vText+" Close("+Amount+")"+"\n");
f.close();
}
Comment