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)
-   -   Wochentag einer beliebigen Kerze ermitteln (http://www.expert-advisor.com/forum/showthread.php?t=3392)

Deepack 28.12.13 22:31

Wochentag einer beliebigen Kerze ermitteln
 
bin gerade am auswerten wie es sich um wochentage verhält

vl kann das codestück jemand brauchen
Code:



int xdayofweek(int Bar)   
{

int y = StrToDouble(StringSubstr(TimeToStr(Time[Bar],TIME_DATE),0,4));
int m = StrToDouble(StringSubstr(TimeToStr(Time[Bar],TIME_DATE),5,2));
int d = StrToDouble(StringSubstr(TimeToStr(Time[Bar],TIME_DATE),8,2));


  static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
 
    y -= m < 3;
 
  double x = (y + y/4 - y/100 + y/400 + t[m-1] + d);
  int z = (x / 7);
   
  return( x - (z*7));
 
}

die funktion gibt einen wert von 0 - 6 retour
0 - Sonntag
...
6 - Samstag

fxdaytrader 29.12.13 15:42

warum so umständlich?

das geht auch:

Code:

int GetDayOfWeek(int bar) {
 return(TimeDayOfWeek(iTime(NULL,0,bar)));
}

und wenn man dann gleich den text haben will:

Code:

string DayToStr(int day) {
 switch (day)        {
  case 0: return("sunday");
  case 1: return("monday");
  case 2: return("tuesday");
  case 3: return("wednesday");
  case 4: return("thursday");
  case 5: return("friday");
  case 6: return("saturday");
  default: return("unknown");
 }
}

könnte man sich das anzeigen lassen bspw. via
Code:

Comment("current day is "+DayToStr(GetDayOfWeek(0)));
:)

Deepack 29.12.13 17:01

fuck

und ich lese mich zum trottel auf wikipedia usw...
bis das codestück funktioniert

danke :)


Alle Zeitangaben in WEZ +2. Es ist jetzt 17:46 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