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

日线高低点通道指标 Daily HL.mq4

Daily HL指标绘制日线高低点通道。

图表:Daily HL指标

源码:

//+------------------------------------------------------------------+
//|                                                      Daily HL.mq4|
//|                                                  Written by: Ice |
//+------------------------------------------------------------------+
#property copyright "2005 Free software for trader"
#property link      "http://www.125808047.com/"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red

datetime BT[];
double YesterdayHigh[50];
double YesterdayLow[50];
double YesterdayClose[50];

double HighArray[];
double LowArray[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,HighArray);
IndicatorShortName("High Line");

SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,LowArray);
SetIndexLabel(3,"Low Line");
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 counted_bars=IndicatorCounted();

ArrayResize(BT, Bars); Print("Bars = " + Bars);
ArrayCopySeries(BT, MODE_TIME);
ArrayCopySeries(YesterdayHigh, MODE_HIGH, Symbol(), PERIOD_D1);
ArrayCopySeries(YesterdayLow, MODE_LOW, Symbol(), PERIOD_D1);
ArrayCopySeries(YesterdayClose, MODE_CLOSE, Symbol(), PERIOD_D1);

int od = 0;
int dd = 0;

double HighLine;
double LowLine;

for (int i = 0; i <= Bars; i++) {
if (TimeDay(BT[i]) != od) {
dd++;
HighLine = YesterdayHigh[dd-1];
LowLine = YesterdayLow[dd-1];
od = TimeDay(BT[i]);
}

HighArray[i] = HighLine;
LowArray[i]=LowLine;
}
return(rates_total);
}
打赏
版权所有转载请注明标题及链接:峰汇在线 » 日线高低点通道指标 Daily HL.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏