Hello, trying since days to geht Event from csv file plotted into AB Chart. Somehow i don't get the correct way from String MMDDYYY to something like a datenum() or so.
This is the idea but only a rough drawing.
Maybe someboday can help. Thanks in advance
filename = "C:\\AmiBroker\\Events\\events.txt";
function StrToDatenum(YearStr,MonthStr,DayStr)
{
result = (10000*YearStr-1900)+
(100*Monthstr)+
DayStr;
return result;
}
fh = fopen(filename, "r");
if (fh)
{
while (! feof(fh))
{
line = fgets(fh);
if (StrLen(line) > 0)
{
// Datum und Event extrahieren
dateStr = StrExtract(line, 0, ";");
YearStr = StrToNum(StrLeft(DateStr,4));
MonthStr = StrToNum(StrMid(DateStr,4,2));
DayStr = StrToNum(StrRight(DateStr,2));
eventText = StrExtract(line, 1, ";");
eventcategory = StrExtract(line, 2, ";");
// Convert date
eventDate = StrToDateNum(YearStr,MonthStr,DayStr);
// find position in Chart
for (i = 0; i < BarCount; i++)
{
if (DateNumOrWhatever[i] == eventDate)
{
// plot eventText vertical
PlotSomehowVerticalText(eventText);
}
}
}
}
fclose(fh);
}