Thanks for your reply.

I have modified the script as follows. It's the full script. The error it's throwing now like this.

Error 062: Can't open (wb:22)


It doesn't create a new .txt file nor deletes the existing file with the below script. However, it seems to load the data and do other things except dealing with file functions.

Thanks.


Script starts here

====


var objective()
{
return ((var)(NumWinLong+NumWinShort))/(NumLossLong+NumLossShort);
}

int m;
m =1;
int v = 0;
int endtime,starttime;






function run()
{



starttime=timer();


m = m+1;


if (m==1)
{
print("Timer");

timer();
v = timer();

print(v);
}

char name1[200] ;
name1 = "c:\\zorro\\strategy\\test1.txt";
string content="";
int length=0;

set(LOGFILE|TESTNOW);
BarPeriod = 5;
LookBack = 110;
NumWFOCycles = 20;
NumCores = -1;
PlotHeight1 = 340;
PlotWidth = 800;

set(BINARY);
WinPayout = 85;
LossPayout = 0;

LifeTime = 1;
int TimePeriod = optimize(20,10,100);
var Threshold = 0.008*(HH(TimePeriod)-LL(TimePeriod));


if(NumOpenLong+NumOpenShort == 0)
{
if(HH(TimePeriod) - priceClose() < Threshold)
{



printf(strf("\nDone Sell!--",m));


Sleep(3000);
if (file_length(name1)>0)
{
file_delete (name1);
}
file_write (name1, content, 0);



}
else if (priceClose() - LL(TimePeriod) < Threshold)
{





printf(strf("\nDone Buy!--",m));


Sleep(3000);
if (file_length(name1)>0)
{
file_delete (name1);
}
file_write (name1, content, 0);



}
}

}