My expert keeps writing the data line in CSV file and repeating it over and over at every tick after its done. Please tell me how to solve this problem
Tank you for your replay, here is my code where I realy use FileWrite Code inside the conditional-if. Also attached copy of the CSV file Page.
int handle=FileOpen("mydata.csv",FILE_CSV|FILE_READ|FILE_WRITE,';'); if(handle>0) { //---- add data to the end of file FileWrite(handle,"TIME_MINUTES","TIME_SECONDS","Fibo_1","Fibo_2"); if ( MACD_MAIN<MACD_Sig ) {FileSeek(handle, 0, SEEK_END); FileWrite(handle,TIME_MINUTES, TIME_SECONDS,Fibo_1,Fibo_2); } FileClose(handle); handle=0; }
The following code will allow your FileWrite code to write data to the csv file one time only.
If you want to write data to the file every time a new minute starts, the conditional-if controlling the FileWrite code will have to be revised.
int Counter;
if(Counter==0) // this conditional-if controls the FileWrite code and allows the FileWrite code to be accessed only one time
{ // Begin Brace for Counter conditinal-if
Counter=1;
int handle=FileOpen("mydata.csv",FILE_CSV|FILE_READ|FILE_WRITE,';');
if(handle>0)
{
//---- add data to the end of file
FileWrite(handle,"TIME_MINUTES","TIME_SECONDS","Fibo_1","Fibo_2");
if ( MACD_MAIN<MACD_Sig )
{FileSeek(handle, 0, SEEK_END);
FileWrite(handle,TIME_MINUTES, TIME_SECONDS,Fibo_1,Fibo_2);
}
FileClose(handle);
handle=0;
}
} // End Brace for Counter conditional-if
The following code will allow your FileWrite code to write data to the csv file one time only.
If you want to write data to the file every time a new minute starts, the conditional-if controlling the FileWrite code will have to be revised.
int Counter;
if(Counter==0) // this conditional-if controls the FileWrite code and allows the FileWrite code to be accessed only one time
{ // Begin Brace for Counter conditinal-if
Counter=1;
int handle=FileOpen("mydata.csv",FILE_CSV|FILE_READ|FILE_WRITE,';');
if(handle>0)
{
//---- add data to the end of file
FileWrite(handle,"TIME_MINUTES","TIME_SECONDS","Fibo_1","Fibo_2");
if ( MACD_MAIN<MACD_Sig )
{FileSeek(handle, 0, SEEK_END);
FileWrite(handle,TIME_MINUTES, TIME_SECONDS,Fibo_1,Fibo_2);
}
FileClose(handle);
handle=0;
}
} // End Brace for Counter conditional-if
The following code will allow your FileWrite code to write data to the csv file one time only.
If you want to write data to the file every time a new minute starts, the conditional-if controlling the FileWrite code will have to be revised.
int Counter;
if(Counter==0) // this conditional-if controls the FileWrite code and allows the FileWrite code to be accessed only one time
{ // Begin Brace for Counter conditinal-if
Counter=1;
int handle=FileOpen("mydata.csv",FILE_CSV|FILE_READ|FILE_WRITE,';');
if(handle>0)
{
//---- add data to the end of file
FileWrite(handle,"TIME_MINUTES","TIME_SECONDS","Fibo_1","Fibo_2");
if ( MACD_MAIN<MACD_Sig )
{FileSeek(handle, 0, SEEK_END);
FileWrite(handle,TIME_MINUTES, TIME_SECONDS,Fibo_1,Fibo_2);
}
FileClose(handle);
handle=0;
}
} // End Brace for Counter conditional-if
Unfortunatly, There are no change in the CSV file, the data line is still repeated.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
My expert keeps create, open CSV file, and writing the data line in CSV file. When I open the CSV file I find that the data line was written and repeated many times.
Please tell me how to solve this problem?