Recalling functional errors

 

i am still working on programming good friday. but i happilly announce i am on the last step! (horray!)

i constantly have been double checking to make sure that this function has been spitting out the correct dates, but time and time again i get up to three diffrent dates each year, after modification and modification, and small adjustment after small adjustment to no avail.

here are the dates i'm wanting it to return.

04/07/04

04/27/05

04/19/06

here's the function

int goodfriday(int & gmonth, int & gday)

{

double cycledays = 29.5306;//approxamation of how long it takes the moon to return to a full moon

int month = 12;//starting full moon is in December

double day = 9;//starting full moon in in December 9

bool FullMoon = False;//self-explanatory

int year = 1990;//starting full moon is in December 9, 1990

gmonth = 0;//month good friday occurs in

gday = 0;//day of the month good friday occurs

int Mday = 0;//number of days in february, determined below

double day2 = 0;//value used to seperate the decimal from the day's value

int day3 = 0;//full moon's day withought decimals

bool Goccur = False;//makes sure good friday already hasn't occured this year

{

//beginning time of the full moon

if (Month() == month && Day() == day && Year() == year)

{

FullMoon = True;

}

else

{

FullMoon = False;

}

// cycles through the days to determine the next full move

if (Month() == month && Day() == day + cycledays && Year() == year)

{

FullMoon = True;

}

//continues the cycle for the months with 31 days in them

if ((Month() == 1 || Month() == 3 || Month() == 5 || Month() == 7 || Month() == 8 || Month() == 10 || Month() == 12) && day + cycledays > 31)

{

month++;

day = day + cycledays - 31;

}

//continues the cycle for the months with 30 days in them

if ((Month() == 4 || Month() == 6 || Month() == 9 || Month() == 11) && day + cycledays > 30)

{

month++;

day = day + cycledays - 30;

}

//resets the months after december is over

if (month > 12)

{

month = 1;

year++;

}

//expression determines if we are in a leap year to determine whether there are 28 or 29 days in february

if (Month() == 2)

{if ((MathMod(Year(),4) == 0) && (((MathMod(Year(),100) == 0) && (MathMod(Year(),400) == 0)) || (MathMod(Year(),100) != 0))) Mday = 29; else Mday = 28;}

//resets the days after february finishes

if (Month() == 2 && day + cycledays > Mday)

{

month++;

day = day + cycledays - Mday;

}

//determines what difference is required to round the day count down to an integer

{day2 = (NormalizeDouble(day,0) - NormalizeDouble(day,4));}

//expression rounds the day value down to an integer

if (MathRound(day2) == 1)

{

day3 = day - day2;

}

//determines exact day of full moon

if((day3 == Day()) && (month == Month()))

{

FullMoon = True;

}

//last string of code translates good friday from the phases of the moon

if(Goccur == False && ((Month() == 3 && Day() > 21) || Month() == 4) && DayOfWeek() == 3 && (Day() + 4 > day3))

{

gmonth = Month();

gday = Day();

Print ("Today is Good Friday");

Goccur = True;

}

//resets Goccur each year

if(Month() == 12)

{

Goccur = False;

}

}

}

and here's a few quick explenations.

i made day3 equal to the day when the full moon occurs, withought the decimal. (integer)

Goccur is supposed to be used to only allow 1 good friday per year, but it's not hard to notice it's not working the way i wanted it to.

variables day and month are the day and month a full moon occurs.

Files:
 
Eaglehawk:
i am still working on programming good friday. but i happilly announce i am on the last step! (horray!)

i constantly have been double checking to make sure that this function has been spitting out the correct dates, but time and time again i get up to three diffrent dates each year, after modification and modification, and small adjustment after small adjustment to no avail.

here are the dates i'm wanting it to return.

04/07/04

04/27/05

04/19/06

here's the function

int goodfriday(int & gmonth, int & gday)

{

double cycledays = 29.5306;//approxamation of how long it takes the moon to return to a full moon

int month = 12;//starting full moon is in December

double day = 9;//starting full moon in in December 9

bool FullMoon = False;//self-explanatory

int year = 1990;//starting full moon is in December 9, 1990

gmonth = 0;//month good friday occurs in

gday = 0;//day of the month good friday occurs

int Mday = 0;//number of days in february, determined below

double day2 = 0;//value used to seperate the decimal from the day's value

int day3 = 0;//full moon's day withought decimals

bool Goccur = False;//makes sure good friday already hasn't occured this year

{

//beginning time of the full moon

if (Month() == month && Day() == day && Year() == year)

{

FullMoon = True;

}

else

{

FullMoon = False;

}

// cycles through the days to determine the next full move

if (Month() == month && Day() == day + cycledays && Year() == year)

{

FullMoon = True;

}

//continues the cycle for the months with 31 days in them

if ((Month() == 1 || Month() == 3 || Month() == 5 || Month() == 7 || Month() == 8 || Month() == 10 || Month() == 12) && day + cycledays > 31)

{

month++;

day = day + cycledays - 31;

}

//continues the cycle for the months with 30 days in them

if ((Month() == 4 || Month() == 6 || Month() == 9 || Month() == 11) && day + cycledays > 30)

{

month++;

day = day + cycledays - 30;

}

//resets the months after december is over

if (month > 12)

{

month = 1;

year++;

}

//expression determines if we are in a leap year to determine whether there are 28 or 29 days in february

if (Month() == 2)

{if ((MathMod(Year(),4) == 0) && (((MathMod(Year(),100) == 0) && (MathMod(Year(),400) == 0)) || (MathMod(Year(),100) != 0))) Mday = 29; else Mday = 28;}

//resets the days after february finishes

if (Month() == 2 && day + cycledays > Mday)

{

month++;

day = day + cycledays - Mday;

}

//determines what difference is required to round the day count down to an integer

{day2 = (NormalizeDouble(day,0) - NormalizeDouble(day,4));}

//expression rounds the day value down to an integer

if (MathRound(day2) == 1)

{

day3 = day - day2;

}

//determines exact day of full moon

if((day3 == Day()) && (month == Month()))

{

FullMoon = True;

}

//last string of code translates good friday from the phases of the moon

if(Goccur == False && ((Month() == 3 && Day() > 21) || Month() == 4) && DayOfWeek() == 3 && (Day() + 4 > day3))

{

gmonth = Month();

gday = Day();

Print ("Today is Good Friday");

Goccur = True;

}

//resets Goccur each year

if(Month() == 12)

{

Goccur = False;

}

}

}

and here's a few quick explenations.

i made day3 equal to the day when the full moon occurs, withought the decimal. (integer)

Goccur is supposed to be used to only allow 1 good friday per year, but it's not hard to notice it's not working the way i wanted it to.

variables day and month are the day and month a full moon occurs.

last problem solved, new one found!

2006.11.06 22:44:53 2006.03.22 00:00 Starter EA EURUSD,Daily: Today is Good Friday

2006.11.06 22:44:41 2005.03.23 00:00 Starter EA EURUSD,Daily: Today is Good Friday

2006.11.06 22:44:25 2004.03.24 00:00 Starter EA EURUSD,Daily: Today is Good Friday

2006.11.06 22:44:20 Starter EA inputs: MagicNumber=0; Lots=0.1; Slippage=3; StopLoss=5; TakeProfit=30; TrailingStop=15; MaxOpenTrade=1;

2006.11.06 22:44:13 Starter EA EURUSD,Daily: loaded successfully

now i get the Goccur to work right, but now i'm getting the wrong dates.

don't have time to solve the problem now, may need assistance, may not. i'll keep everyone posted

 
 
JosTheelen:
Will this help? http://kenhamady.com/form25.shtml

oy yoi yoi, no comments . i don't do well with reading code when there's not documentation on a scope past "this chunk of code calculates good griday".

i don't easily take in code i haven't made unless i'm sure it does what it says it does. and the whole algorithm this uses just makes me more confused, frankly.

thanks for the suggestion though, i appreciate your input.

 

OK. If you get stuck, mail me and I can translate it to MT4.