Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools

Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools (http://www.expert-advisor.com/forum/index.php)
-   Programmierung MQL4 (http://www.expert-advisor.com/forum/forumdisplay.php?f=220)
-   -   Werte in Datei schreiben - läuft, kommt aber nicht in der Datei an. (http://www.expert-advisor.com/forum/showthread.php?t=2644)

Indi 18.01.13 21:29

Werte in Datei schreiben - läuft, kommt aber nicht in der Datei an.
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo im Forum,

habe versucht aus den einschlägigen Hilfen ein EA zu schreiben, dass mir div. Werte fortlaufend in eine CSV schreiben soll. Hat einmal funktioniert und dann nie wieder.
Die Datei gibt es und die erste Zeile ist beschrieben.
Er gibt mir keine Fehlermeldung aus, schreibt braf unter Experten, aber nicht in die Datei.

Danke für jede Hilfe!!!

Herzliche Grüße,
Wolfgang

Code:

#define __STRATEGY_MAGIC 1011787487

//Inputs

//Declaration
double _Bollinger_Bands;
double _Ask;
double _Bid;
double _Day_Low;
double _Day_High;

int start(){

  //Level 1
  _Bollinger_Bands = iBands(Symbol(),0,20,2,0,0,1,0);
  _Ask = Ask;
  _Bid = Bid;
  _Day_Low = MarketInfo(Symbol(),MODE_LOW);
  _Day_High = MarketInfo(Symbol(),MODE_HIGH);

  //Level 2
  if(true)Print(_Ask,_Bid,_Day_Low,_Day_High,_Bollinger_Bands,"{Time}");
 
 
  //--in-Datei-schreiben-----------------------------------------------------
 
  int Handle,                       
  Qnt_Symb;                         
  string File_Name="news.csv";                                  //File name 
  Handle=FileOpen(File_Name,FILE_CSV|FILE_READ|FILE_WRITE,";");  //File opening
 
  if(Handle==-1)                                                //File opening fails
    {
    Alert("Datei kann nicht geöffnet werden. ");                //Error message
    return;                                                      //Exit start()     
    }
     
  FileSeek(Handle, 0, SEEK_END);                                //go to end of file
  Qnt_Symb=FileWrite(Handle,_Ask,_Bid);                          //Writing to the file
 
  if(Qnt_Symb < 0)                                              //If failed
    {
    Alert("Datei kann nicht beschrieben werden",GetLastError()); //Message
    FileClose(Handle);                                        //File closing
    return;                                                      //Exit start()     
    }
   
  FileClose(Handle);                                          //File closing
  //Alert("The ",File_Name," file created.");// Message
  return;                                                        //Exit start()

  //--in-Datei-schreiben---------------------------------------------------------------
 
  return(0); 
}


Indi 18.01.13 22:16

Ich hab´s gefunden:

http://www.expert-advisor.com/forum/...html#post16785

Hoschie 19.01.13 10:35

Das ist meine Methode, die funktioniert. Vergleicht das mit deinem FileWrite:

int Write(string str, string filename)
{
//Write log file
int handle;
handle = FileOpen(filename,FILE_READ|FILE_WRITE|FILE_CSV,"/t");
FileSeek(handle, 0, SEEK_END);
FileWrite(handle," Time " + TimeToStr(CurTime(),TIME_DATE|TIME_SECONDS) + ": " + str);
FileClose(handle);
if(handle<1)
{
Print("File my_data.dat not found, the last error is ", GetLastError());
return(false);
}

Print(str);
}

Hoschie 19.01.13 10:36

Das ist meine Methode, die funktioniert. Vergleicht das mit deinem FileWrite:

PHP-Code:


int Write
(string strstring filename)
{
//Write log file
   
int handle
   
handle FileOpen(filename,FILE_READ|FILE_WRITE|FILE_CSV,"/t");
   
FileSeek(handle0SEEK_END);      
   
FileWrite(handle," Time " TimeToStr(CurTime(),TIME_DATE|TIME_SECONDS) + ": " str);
   
FileClose(handle);
    if(
handle<1)
    {
     Print(
"File my_data.dat not found, the last error is "GetLastError());
     return(
false);
    }

    Print(
str);




Alle Zeitangaben in WEZ +2. Es ist jetzt 13:20 Uhr.

Powered by vBulletin® Version 3.8.5 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.1
Powered by vBCMS® 2.7.0 ©2002 - 2024 vbdesigns.de
Copyright ©2009 - 2023 by Expert-Advisor.com - Das Metatrader Forum