Wininet and assigment ?

 

Hi all,


I need some help - I'm trying to automate this process : Each day, I need to assign a new value to specific variables. I would like to upload a file on a server and that the expert advisor will be able to look for this file via internet and change the value of the variables with the new ones.



Example : Two levels as double variables in the expert advisor code : one to buy and one to sell ( variables : LevelBuy and LevelSell)

On my file on internet (csv file with LevelBuy = 1.5000 ; LevelSell = 1.4000)


I'm able to automate the process of downloading the file to my experts/file folder but how to assign theses values to each one of my variables ?



Thanks for your help.

 
 

Thanks, I understand much better the logic behind the file functions.

However, I wrote this code to read the file and it seems it doesn't work. (I have no error message and the file is in my tester/files folder since I'm testing my code with the strategy tester.


if (FileLu ==False) // This line to check if the file was already open or not to avoid the error : too many opened files
{
int handle;
handle=FileOpen(FileName,FILE_BIN|FILE_READ);
if(handle<1)
{
Print("File not found, the last error is ", GetLastError());
return(false);
}

LevelBuy=FileReadDouble(handle,DOUBLE_VALUE);
LevelSell=FileReadDouble(handle,DOUBLE_VALUE);

FileClose(handle);
}
FileLu = True;


How do I have to present the values in the file : I try to add an delimiter like this handle=FileOpen(FileName,FILE_BIN|FILE_READ,';'); but MetaTrader returns this error : wrong delimiter for a binary file. Same thing with ','.


I try also to write each value on a new line but nothing happen neither.



Thanks

 
I add some code so i can see the value of the variable before and after the file reading and it seems that after, the value is always 0.0000000000.
 
Are you reading CSV or BIN (binary) file?
 

I try with both types but still not working.


I try with the following options :

EURUSD.csv with : 1.5000;1.4000;1.5040;etc...
EURUSD.set with : 1.5000;1.4000;1.5040;etc...

EURUSD.txt with : 1.5000;1.4000;1.5040;etc...

EURUSD.txt with : 1.5000,1.4000,1.5040,etc...

EURUSD.set with : 1.5000
1.4000
1.5040
etc...



any ideas ?


Thanks
 

attach your file for verification

in a CSV file, the data is stored as ascii characters.

in a BIN file, characters are stored as characters, numbers are stored as integer, long integer, double, etc.

You say you create the file as CSV, but then you read it as BIN... wrong...

 

Here you go !



Please find attached the EA and the file i'm using for my tests.


The EA code works fine without the whole reading process. The concept is that if we have a bar opening upper the BObuy level and under BOBuy + MaxPipsDiff, the EA will enter. Same concept with sell order.

 
And here the txt file
Files:
eurusd.txt  1 kb
 
Well, what's the problem at his point?
 
phy:
Well, what's the problem at his point?

The problem is that the EA is not able to use the levels after reading them on the txt file. As you can see, I ask the EA to draw a line at this level (this part works fine and the line is draw at the correct price) but when it comes to open a trade, the EA canno't use the level and I don't understand why. I think it something to do with a misinterpretation of the variable type but cann't see by myself where the problem is.



Thanks

Reason: