1. Hast Du AutoTrading aktiviert
2. Die Datei entsteht erst mit der ersten neuen Kerze
3. Die Datei wird wenn Du das im Strategietester laufen lässt unter tester/files abgelegt und im Live Modus unter MQL4/Files
2. Hast du den "void Code richtig eingebunden? Wie hier (das ist der komplette EA):
Code:
//+------------------------------------------------------------------+
//| testdatei.mq4 |
//| Copyright 2020, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
InDatei();
}
//+------------------------------------------------------------------+
void InDatei()
{
double SPREAD=Bid-Ask;
string symbol=Symbol();
string TextDatei;
TextDatei=StringConcatenate("TESTSPREAD","-",symbol,".","txt");
if(TimeCurrent() == Time[0])
{
int handle;
handle = FileOpen(TextDatei,FILE_READ|FILE_WRITE|FILE_TXT,"/t"); // Datei wird unter \MQL4\Files abgelegt
FileSeek(handle, 0, SEEK_END);
FileWrite(handle,TimeToString(Time[0]),symbol,"SPREAD: ",NormalizeDouble(SPREAD,1)); /*nach “handle,” kommt das was in die Datei geschrieben wir mit Komma getrennt */
FileClose(handle);
if(handle<1)
{
Print("File my_data.dat not found, the last error is ", GetLastError());
}
//Print(str);
}
}