See above. I would bei grateful for an answer
- week of the month
- How to get day of week for yesterday ?
- Very easy and profitable trading strategy
int dayofweek; MqlDateTime date; datetime time = iTime(Symbol(), PERIOD_CURRENT, 0); TimeToStruct(time, date); if(date.day == 1){ dayofweek = date.day_of_week; }
Something like this, all depending of how you want to use it of course.
day_of_week = (0-Sunday, 1-Monday, ... 6-Saturday)
#property strict #define HR2400 (PERIOD_D1 * 60) // 86400 = 24 * 3600 = 1440 * 60 : datetime now = TimeCurrent(); // April 7, 2019 Sunday(0) int dom = TimeDay(now); // 7 datetime first = now - HR2400 * (dom - 1); // April 1, 2019 Monday(1) int firstDay = TimeDay(first); // 1Find today. Subtract to the first. Find that day.
for any month :
int month_bar = 0; int dayOfWeek = TimeDayOfWeek(iTime(_Symbol, PERIOD_MN1, month_bar));
paul selvan: for any month :
On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors
before accessing prices.
Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum
On MT5: Unless the chart is that specific pair/TF, you must Synchronize the terminal Data from the Server.
Timeseries
and Indicators Access / Data Access - Reference on
algorithmic/automated trading language for MetaTrader 5
Synchronize Server Data
with Terminal Data - Symbols - General - MQL5 programming forum
the number of monthly bar is limited as :
int max_monthly_bar= iBars(_Symbol,PERIOD_MN1)-1;
Print("First day on current month is: ",TimeDayOfWeek(datetime(TimeYear(TimeCurrent())+"."+TimeMonth(TimeCurrent())+".1"))," Remember: (0 means Sunday,1,2,3,4,5,6)");
here is a replacement function from mql4 for mql5:
//+------------------------------------------------------------------+ int TimeDayOfWeek(datetime pDate) { MqlDateTime date; TimeToStruct(pDate, date); return date.day; } //+------------------------------------------------------------------+
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