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
Moin Moin,
I wrote an EA which goes in for a position always Fridays if some conditions are given. With the conditions everything is good, but with the 'time term' I have some trouble. the code is as follows:
//Wochentag/Stunde/Minute der Woche/Stunde bestimmen
MqlDateTime lokalzeit;
TimeToStruct(TimeLocal(),lokalzeit);
int wochentag = lokalzeit.day_of_week;
int stunde = lokalzeit.hour;
int minute = lokalzeit.min;
int sekunde = lokalzeit.sec;
For control reasons I print out the time on the chart the bold part:
//Verschiedene Informationen im MT5 auf Chart ausgeben
Comment(Symbol(),",",EnumToString(Period()),"\n",
"Time Bar opened: " ,TimeToString(timebaropen,TIME_DATE|TIME_SECONDS),"\n",
"Open: " ,DoubleToString(open,Digits()),"\n",
"High: " ,DoubleToString(high,Digits()),"\n",
"Low: " ,DoubleToString(low,Digits()),"\n",
"Close: " ,DoubleToString(close,Digits()),"\n",
"Volume: ",IntegerToString(volume),"\n",
"Bars: " ,IntegerToString(bars),"\n",
"Differenz: ",DoubleToString(Diff,Digits()),"\n",
/* "Zeit Aktuell: " ,TimeToString(aktuell,TIME_DATE|TIME_SECONDS),"\n",
"Zeit Trade Server: " ,TimeToString(tradeserver,TIME_DATE|TIME_SECONDS),"\n",
"Zeit Local: ",TimeToString(local,TIME_DATE|TIME_SECONDS),"\n",
"Zeit GMT: " ,TimeToString(gmt,TIME_DATE|TIME_SECONDS),"\n",*/
"Wochentag: " ,IntegerToString(wochentag),"\n",
"Stunde: " ,IntegerToString(stunde),"\n",
"Minute: " ,IntegerToString(minute),"\n",
"Sekunde: " ,IntegerToString(sekunde),"\n"
"TP: " ,DoubleToString(TP,Digits()),"\n",
"SL: " ,DoubleToString(SL,Digits()),"\n",
"Low: " ,DoubleToString(low,Digits()),"\n",
"Close: " ,DoubleToString(close,Digits()),"\n"
/* "LongSignal: " ,IntegerToString(ls),"\n",
"ShortSignal: " ,IntegerToString(ss),"\n"*/
);
The problem:
if I make a backtest, it works quite good for 2018 and part of 2017. But for more early time, the term
MqlDateTime lokalzeit;
TimeToStruct(TimeLocal(),lokalzeit);
seems not to work. That means for the time before 2017 I get the value '0' for 'stunde' and 'minute' . that means i can have no signal though the conditions are fulfilled. What I just discovered while writing here: For the early time, the seconds count from 0 to 59 and then set the day.of.week +1. That means in this contents the week contains out of 5 minutes..... Somewhere there must be the fault. can it be that it is the historic data which is somehow wrong formatted?
Please for suggestions