
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I try to use that code but it does not work..
I placed file week.txt in....
\experts\files\week.txt
abd it contains ..
2007.03.30;15:00;Koko;USA;March;-0.5%;-0.8%;
and ReadFromFile in..
\experts\indicators\readfromfile.mg4
//+------------------------------------------------------------------+
//| ReadFromFile.mq4 |
//| ·•°njel°•·
//| iamnotlinked |
//+------------------------------------------------------------------+
#property copyright "·•°njel°"
#property link "iamnotlinked"
#property show_inputs
extern bool DisplayText = true;
extern bool Japan = true;
extern bool USA = true;
extern bool Germany = true;
extern bool ES = true;
extern bool GB = true;
extern bool Canada = true;
extern string FileName = "week.txt";
int start()
{
ObjectsDeleteAll();
int handle;
handle=FileOpen(FileName,FILE_CSV|FILE_READ,';');
if(handle<1)
{
Print("File not found, the last error is ", GetLastError());
return(false);
}
int i= 0;
while(!FileIsEnding(handle))
{
string sDate=FileReadString(handle); // Date
string sTime=FileReadString(handle); // Time
string sDescription=FileReadString(handle); // Description
string sCountry=FileReadString(handle); // Country
string sPeriod=FileReadString(handle); // Period
string sCurrent=FileReadString(handle); // Current value
string sForecast=FileReadString(handle); // Expected
FileReadString(handle); // null
i++;
datetime dt = StrToTime(sDate+" "+sTime);
color c = Red;
if (sCountry == "Japan") c = Yellow;
if (sCountry == "USA") c = White;
if (sCountry == "Germany") c = Green;
if (sCountry == "ES") c = Blue;
if (sCountry == "GB") c = Orange;
if (sCountry == "Canada") c = Gray;
if ((sCountry == "Japan") && (!Japan)) continue;
if ((sCountry == "USA") && (!USA)) continue;
if ((sCountry == "Germany") && (!Germany)) continue;
if ((sCountry == "ES") && (!ES)) continue;
if ((sCountry == "GB") && (!GB)) continue;
if ((sCountry == "Canada") && (!Canada)) continue;
if (DisplayText)
{
ObjectCreate("x"+i, OBJ_TEXT, 0, dt, Close[0]);
ObjectSet("x"+i, OBJPROP_COLOR, c);
ObjectSetText("x"+i, sDescription + " "+ sCountry + " " + sPeriod + " " + sCurrent + " " + sForecast, 8);
ObjectSet("x"+i, OBJPROP_ANGLE, 90);
}
ObjectCreate("y"+i, OBJ_VLINE, 0, dt, Close[0]);
ObjectSet("y"+i, OBJPROP_COLOR, c);
ObjectSet("y"+i, OBJPROP_STYLE, STYLE_DOT);
ObjectSet("y"+i, OBJPROP_BACK, true);
ObjectSetText("y"+i, sDescription + " "+ sCountry + " " + sPeriod + " " + sCurrent + " " + sForecast, 8);
}
return(0);
}
//+------------------------------------------------------------------+