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

以昨日最高价和最低价创建通道 LastDayHighLow.mq4

LastDayHighLow 指标以昨日最高价和最低价创建通道。

图表:LastDayHighLow 指标

源码:

//+------------------------------------------------------------------+
//|                                               LastDayHighLow.mq4 |
//|                                     Copyright 2008, Serega Lykov |
//+------------------------------------------------------------------+
#property copyright "Copyright 2008, Serega Lykov"
#property link      "http://www.125808047.com"

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

double HighBuffer[];
double LowBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   IndicatorDigits(Digits);
   IndicatorShortName("Last Day High/Low");
   SetIndexBuffer(0,HighBuffer);
   SetIndexBuffer(1,LowBuffer);
   SetIndexLabel(0,"Last Day High");
   SetIndexLabel(1,"Last Day Low");
   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();
   if(counted_bars < 0) return(-1);
   if(counted_bars>0) counted_bars--;
   for(int i=0; i<=counted_bars; i++)
     {
      HighBuffer[i] = iHigh(NULL,PERIOD_D1,iBarShift(NULL,PERIOD_D1,Time[i])+1);
      LowBuffer[i] = iLow(NULL,PERIOD_D1,iBarShift(NULL,PERIOD_D1,Time[i])+1);
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » 以昨日最高价和最低价创建通道 LastDayHighLow.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏