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

[Deleted]  

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?

[Deleted]  

You need to place your FileWrite code inside a conditional-if. How often do you want to write data to the file? One time, or once every so often? Let me know and I will give you some code.


Cheers

[Deleted]  

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.


CSV page

[Deleted]  
osmanai wrote >>

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.


CSV 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;
    }
[Deleted]  

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
[Deleted]  
raft wrote >>

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

raft
wrote
>>

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.

[Deleted]  

I thought the condition is the problem, so I used the cross of two lines of MACD, but the result is the same, the data lines still repeated.