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

CandRelation_v2.mq4

CandRelation_v2指标在副图绘制曲线,反映价格波动开盘、最高、最低价之间的变化。

图表:

CandRelation_v2指标

源码:

//+------------------------------------------------------------------+
//|                                              CandRelation_v2.mq4 |
//|                                                   Copyright @2008|
//+------------------------------------------------------------------+
#property copyright ""
#property link      "http://www.125808047.com"
#property indicator_separate_window

#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Blue
#property indicator_color3 Crimson
#property indicator_level1 0.3
#property indicator_level2 0.5
#property indicator_level3 0.7
#property indicator_maximum 1
#property indicator_minimum 0

double Buf1[];
double Buf2[];
double Buf3[];

int OnInit(void)
{
   SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,Buf1);
   SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,Buf2);
   SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,Buf3);
   IndicatorDigits(Digits+2);
   Comment("www.125808047.com");
 return(INIT_SUCCEEDED);
 }

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 counted_bars=IndicatorCounted();
	if (counted_bars<0) return(-1);
	if (counted_bars>0) counted_bars--;
	int lim=Bars-counted_bars+1;

	double HS, LS, BD, CC;
	for(int i=0; i<lim; i++)
	{
		CC=MathMax(High[i]-Low[i], Point);	
		HS=(High[i]-MathMax(Open[i], Close[i]))/CC; 
		LS=(MathMin(Open[i], Close[i])-Low[i])/CC;
		BD=(MathAbs(Open[i]-Close[i]))/CC;
		Buf1[i]=HS; Buf2[i]=BD; Buf3[i]=LS;
	}
	return(rates_total);
}
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » CandRelation_v2.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏