Change:
int Week[];
To:
double Week[];
Yes,you are right ! It does work.
Thank you.
But why? the return value type is int,why it should change to double ?
int TimeDayOfWeek( | datetime date) |
Maybe arrays for indicator buffers should be type of double.
I checked some examples in the MQL4 book,arrays used for indicator buffers are declared as double.
Anyway,Thank you blogzr3 !

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
#property copyright "Copyright ?2009, MetaQuotes Software Corp."
#property link "https://www.metaquotes.net/"
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 6
#property indicator_buffers 1
#property indicator_color1 Blue
int Week[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexBuffer(0,Week);
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_DASH,1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
int i = Bars-counted_bars-1;
datetime di=0;
while(i>=0)
{
di=Time[i];
Week[i]=TimeDayOfWeek(di);//Returns the zero-based day of week (0 means Sunday,1,2,3,4,5,6) for the specified date.
i--;
}
//alert(Week[2]);
// i=TimeDayOfWeek(D'2004.11.2 13:45:45');
// Alert(i);
//----
return(0);
}
//+------------------------------------------------------------------+
But nothing was drawn. I know the codes are not usefull for trading, I coded it just for practice. I am a beginnger.
Anyone tell me where is the wrong ?