user_123:
Hello,
you check with your loop only the latest 25 Bars, if you try it on the H1-chart, then you check only the latest 25 hours.
I hope it helps you?
Unfortunetly no! :( in my original code 25=Bars-1...
The loop is running and the comment writes the days 3 and in the if-else part the day!=3 is always true... ???
I think a got a bug :(
user_123:
Check this line:
in your code is the bracket not at the right position
Me, noob :) i belive in mql4 lol, sorry!
Thank you very much!
Kajos2250: It should find the first candle of Wednesday from right to left on the used time frame
if(TimeDayOfWeek(iTime(Symbol(),Period(),i)!=3)) ... else {... break; }
- If you're looking at the current chart, current period, why use a function call? Just use
if(TimeDayOfWeek(Time[i]!=3))
- Time[i]!=3 is always true and true==1 so you have
if(TimeDayOfWeek(Time[i]!=3)) if(TimeDayOfWeek(true)) if(TimeDayOfWeek(1)) // Thu, 01 Jan 1970 00:00:01 if(TimeDayOfWeek(D'1970.1.1 0:0:1)) if(4) if(true)
- Even fixing it like user_123
said
// if(TimeDayOfWeek(iTime(Symbol(),Period(),i) !=3)) ... if(TimeDayOfWeek(iTime(Symbol(),Period(),i))!=3 ) ... if(TimeDayOfWeek(Time[i] )!=3 )
won't find the first (earliest) Wednesday candle, it finds the last (latest) eitherint i=0; while(TimeDayOfWeek(Time[i ]) != 3) ++i; // Find latest Wednesday while(TimeDayOfWeek(Time[i+1]) == 3) ++i; // Find earliest Wednesday
orint iDOW(int dow=3){ for(int iD1=0; true; ++iD1){ datetime D1time = iTime(Symbol(),PERIOD_D1); int D1dow = TimeDayOfWeek(D1time); if(D1dow == dow) return iBarShift(NULL,0, D1time); } } : comment("found date: "+(string)Time[iDow(3)];

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
Hi everybody!
I wrote an simple script, that can not work.
It should find the first candle of Wednesday from right to left on the used time frame etc: PERIOD_H1, but it can not work and i dont know why.
This code is so simply and am i so idiot i can not write it?? :)
Please somebody help!
Thank you very much!