Windows 10 file_write error

Posted By: mayark

Windows 10 file_write error - 05/30/20 01:10

Hello,

I am getting an error for the last 4 lines of code below. I tried various ways to set the file path but with no luck. I appreciate any help. I know it's basics but I have been trying to get this working for hours with no luck.

Error 062: Can't open test-file_read_EURCHF.par


char name1[200] ;
name1 = "c:\\Zorro\\Strategy\\test1.txt";
string content="";
file_write (name1, content, 0);
Posted By: danatrader

Re: Windows 10 file_write error - 05/30/20 07:45

Cant open par means you need to train the parameters.
Take away all the optimize stuff and it probably works.
Posted By: mayark

Re: Windows 10 file_write error - 05/30/20 13:43

Thanks for your reply. The Problem is, script works as soon as those four rows of code relates to file_read command are removed.

Rest of the code is from the run function from the below article.

https://financial-hacker.com/binary-options-scam-or-opportunity/


I want to capture the Buy/Sell signal in a fext file.
Posted By: AndrewAMD

Re: Windows 10 file_write error - 05/30/20 13:57

Those lines of code and your error are still 100% unrelated to each other. If you can read the code you are describing, you can obviously see that it's not doing anything with the .par file.

If you're not sure what the code is, read the function descriptions in the manual until you understand. Bad things happen when you do not understand your code. wink

Also, the latest version of the Financial Hacker scripts (including all bug fixes) are actually in the zip files listed in the right-hand column. You should use those and not the code in the blog post.
Posted By: mayark

Re: Windows 10 file_write error - 05/31/20 02:53

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);



}
}

}
Posted By: danatrader

Re: Windows 10 file_write error - 05/31/20 07:38

I assume you did try something like that

file_write("c:\\test.log", "123", 0);

it works as soon as you take that simple string out the following section.
Also deleting works fine.

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);

}



When you realize things work once you take away all the variations, I guess maybe one issue is


name1 = "c:\\zorro\\strategy\\test1.txt";

from the manual:

file_write (string name, string content, int length)
Stores the content of a string, series, or other data array in a file.
Posted By: mayark

Re: Windows 10 file_write error - 06/01/20 10:03

Thank you for your answer.
It's still no go for me even with the text file just sits on the c drive or inside a folder. I tried to run the app as the admin user, but it wouldn't work.
Posted By: danatrader

Re: Windows 10 file_write error - 06/01/20 10:48

Did you define name1 = "c:\\zorro\\strategy\\test1.txt"; as a string?
Did you go iterative?

Looks to me, you want too much too fast.
Posted By: mayark

Re: Windows 10 file_write error - 06/01/20 10:56

I downloaded the latest version of Zorro. But in the dropdown list I can't find the broker Fxcm. However it somehow found the account details including the password eventhough I specifically installed it a new directory. Strange.
Posted By: mayark

Re: Windows 10 file_write error - 06/01/20 11:01

Hi Danatrader,

Absolutely not complaining and hopefully not asking too much. I tried many things over the last several days. Just downloaded the latest Zorro version but ran into a different issue as replied earlier.

Yes, I am going in circles but hopefully not asking too much as said earlier.

Ok, fixed the issue after changing as you suggested the variable name1 to string as well as changing the folder permissions and then running zorro app as the admin.
From memory, it was originally using the data type string then I changed it after seeing an example in the forum. I think I will carry on and will keep an eye out for an answer for my new issue with the broker id not appearing in the latest Zorro version's broker list.

Thank you Danatrader and others for your feedback.
Posted By: Spirit

Re: Windows 10 file_write error - 06/01/20 11:04

The hope that reinstalling a latest version magically solves problems is usually in vain. Much better is reading the manual. There you can find how to connect to FXCM.

http://manual.zorro-project.com/fxcm.htm
© 2024 lite-C Forums