Depending on your local TZ and the TZ that your Broker is using I guess the 1st bar of a Monday may not be the 00:00 bar on Monday ? Wednesday should be easy, it will be the 23:00 bar on Wednesday . . .
Xlr8er:
1. The first bar open price of the last recorded Monday (Hour Bar).
2. The last bar close price of the last recorded Wednesday (Hour Bar).
2. The last bar close price of the last recorded Wednesday (Hour Bar).
string PriceToStr(double p){ return( DoubleToStr(p, Digits) ); } : #define SUNDAY 0 #define MONDAY 1 #define WEDNESDAY 3 for (int iWed=0; iWed < Bars; iWed++){ int DOW = TimeDayOfWeek(Time[iWed]); if (DOW == WEDNESDAY) break; // Found last Wed. bar. } for (int iMon=0; iMon < Bars; iMon++){ int DOW = TimeDayOfWeek(Time[iMon+1]); if (DOW == SUNDAY) break; // Found first Mon. bar. } Print( "Open Monday ", TimeToStr(Time[iMon]), " was ", PriceToStr(Open[iMon]) ); Print( "Close Wednesday ", TimeToStr(Time[iWed]), " was ", PriceToStr(Close[iWed]) );

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
1. The first bar open price of the last recorded Monday (Hour Bar).
2. The last bar close price of the last recorded Wednesday (Hour Bar).
Anybody know how to do this ? Ive tried getting the variables as they pass with :
//-------------------------------------------------------
if (currentday == 1 && currenttime == 0)
{
MondayOpenPrice = iOpen(Symbol(),PERIOD_H1,0);
}
//--------------------------------------------------------
The problem with the above is I cant always keep my metatrader running the whole week to keep these variables.
So I will need the EA to look back in history for the first recorded open price on a monday etc...
Thank you so much for your time.