诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 4 > MT4指标 > 正文

日线开盘价通道指标 Daily Open.mq4

Daily Open指标以日线开盘价绘制通道。

图表:Daily Open指标

源码:

//+------------------------------------------------------------------+
//|                                                   Daily Open.mq4 |
//|                                 Copyright @2005, David W. Thomas |
//+------------------------------------------------------------------+
#property copyright "Copyright @2005, David W. Thomas"
#property link      "http://www.125808047.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 MediumSlateBlue
#property indicator_color2 ForestGreen

extern int DailyOpen=0;
extern int EuroOpen=8;

double DailyOpenBuffer[];
double EuroOpenBuffer[];

int indexbegin = 0;
double dailyopen = 0,euroopen=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
	SetIndexStyle(0, DRAW_LINE, STYLE_DASH);
	SetIndexBuffer(0, DailyOpenBuffer);
	SetIndexLabel(0, "Daily Open");
	SetIndexEmptyValue(0, 0.0);
	
		SetIndexStyle(1, DRAW_LINE, STYLE_DASH);
	SetIndexBuffer(1, EuroOpenBuffer);
	SetIndexLabel(1, "Euro Open");
	SetIndexEmptyValue(1, 0.0);

	indexbegin = Bars - 20;
	if (indexbegin < 0)
		indexbegin = 0;
   Comment("www.125808047.com");
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   int i;
	int counted_bars = IndicatorCounted();

	if (counted_bars < 0) counted_bars = 0;
	if (counted_bars > 0) counted_bars--;
	if (counted_bars > indexbegin) counted_bars = indexbegin;

		for (i = indexbegin-counted_bars; i >= 0; i--)
		{
			if ((TimeMinute(Time[i]) == 0) && (TimeHour(Time[i]) - DailyOpen == 0))
				dailyopen = Open[i];
			DailyOpenBuffer[i] = dailyopen;
			
			if ((TimeMinute(Time[i]) == 0) && (TimeHour(Time[i]) - EuroOpen == 0))
				euroopen = Open[i];
			EuroOpenBuffer[i] = euroopen;
		}	
	return(rates_total);
}
打赏
版权所有转载请注明标题及链接:峰汇在线 » 日线开盘价通道指标 Daily Open.mq4
上一篇:
下一篇:
分享到: 更多 (0)

如您觉得此文不错请扫码打赏!

支付宝扫一扫打赏

微信扫一扫打赏