[MT4指标]日周开盘指示
主图指标
mt4指标类型:趋势指标
是否能用在mt4手机版上:否
是否含有未来函数:无
//+------------------------------------------------------------------+
//| Daily-Weekly Open.mq4 |
//| [email protected] |
//| http://www.learncurrencytrading.com/fxforum/blogs/djindyfx/ |
//+------------------------------------------------------------------+
#property copyright "[email protected]"
#property link "http://www.learncurrencytrading.com/fxforum/blogs/djindyfx/"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Red
//---- buffers
double dailyopen;
double weeklyopen;
double line;
double d,w;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE,STYLE_DOT,1);
SetIndexBuffer(0,dailyopen);
SetIndexStyle(1,DRAW_LINE,STYLE_DASHDOT,1);
SetIndexBuffer(1,weeklyopen);
string dopen, wopen;
dopen = "Daily Open";
wopen = "Weekly Open";
IndicatorShortName(dopen);
IndicatorShortName(wopen);
SetIndexLabel(0,dopen);
SetIndexLabel(1,wopen);
SetIndexDrawBegin(0,1);
//SetIndexDrawBegin(1,1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//ObjectDelete("Weekly Open");
//ObjectDelete("Daily Open");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit, i;
//----
if(counted_bars==0)
{//0
//d=Period();
//if (d>240)return(-1);
ObjectCreate("Weekly Open",OBJ_HLINE,0,0,0);
ObjectCreate("Daily Open",OBJ_HLINE,0,0,0);
}//0
if(counted_bars<0) return(-1);
limit=(Bars-counted_bars)-1;
for(i=limit; i>=0; i--)
{//0
if(1==TimeDayOfWeek(Time) && 1!=TimeDayOfWeek(Time[i+1]))
{//1
w=Open;
ObjectMove("Weekly Open",0,Time,line);
}//2
if (TimeDay(Time) !=TimeDay(Time[i+1]))
{//3
d=Open;
ObjectMove("Daily Open",0,Time,line);
}//3
weeklyopen=w;
dailyopen=d;
}//0
//----
return(0);
}
//+------------------------------------------------------------------+
Daily-Weekly%20Open.jpg
