外汇通论坛软件讨论交流区MT4专区 搜罗一个修改后的飞狐的指标,有图

1  /  1  页   1 跳转 查看:1111

搜罗一个修改后的飞狐的指标,有图

搜罗一个修改后的飞狐的指标,有图

//+------------------------------------------------------------------+
//|                                                        HHLL.mq4 |
//+------------------------------------------------------------------+
#property copyright "wfy05@talkforex.com"
#property link      "www.talkforex.com"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Red

#define BUFFER_HIGH  0
#define BUFFER_LOW  1
#define BUFFER_HIGH_ARROW  2
#define BUFFER_LOW_ARROW  3


//---- indicator parameters
extern int nBars = 10;
extern bool ShowAllLine = false;
extern bool ShowArrow = true;

//---- indicator buffers
//high buffers
double MapBufferHigh[];
//low buffers;
double MapBufferLow[];
//high arrow buffers
double MapBufferHighArrow[];
//low arrow buffers;
double MapBufferLowArrow[];

//----

//+------------------------------------------------------------------+
//| Custom indicator initialization function                        |
//+------------------------------------------------------------------+
int init()
  {
  int    draw_begin;
  string short_name;

  draw_begin=nBars-1;
  short_name = "HHLL(";
  IndicatorShortName(short_name+nBars+")");
  IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- drawing settings

  for (int i=0; i < 4; i++) {
      SetIndexStyle(i,DRAW_LINE);
      SetIndexShift(i,0);
      SetIndexDrawBegin(i,draw_begin);
  }
  //---- indicator buffers mapping
  SetIndexBuffer(BUFFER_HIGH,MapBufferHigh);
  SetIndexBuffer(BUFFER_LOW,MapBufferLow);
 
  SetIndexBuffer(BUFFER_HIGH_ARROW,MapBufferHighArrow);
  SetIndexBuffer(BUFFER_LOW_ARROW,MapBufferLowArrow);
 
  SetIndexStyle(BUFFER_HIGH_ARROW,DRAW_ARROW);
  SetIndexStyle(BUFFER_LOW_ARROW,DRAW_ARROW);
  SetIndexArrow(BUFFER_HIGH_ARROW,SYMBOL_ARROWDOWN);
  SetIndexArrow(BUFFER_LOW_ARROW,SYMBOL_ARROWUP);
 
//---- initialization done
  return(0);
  }


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
  int ExtCountedBars;
  if(Bars<=nBars) return(0);
  ExtCountedBars=IndicatorCounted();
//---- check for possible errors
  if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
  if (ExtCountedBars>0) ExtCountedBars--;
//----
  int    i,pos=Bars-ExtCountedBars-1;
//---- initial accumulation
  if(pos<nBars) pos=nBars;

    pos -= nBars;
//---- main calculation loop
  int h, l;
 
  h = Bars;
  l = Bars;
 
  static bool show_h = false, show_l = false;
  string name;
  while(pos>=0)
    {
        MapBufferHigh[pos]=High[Highest(NULL, 0, MODE_HIGH, nBars, pos)];
        MapBufferLow[pos]=Low[Lowest(NULL, 0, MODE_LOW, nBars, pos)];
       
        if (!ShowAllLine) {
            for (i = pos+nBars; i < Bars; i++) {
              if (Close > MapBufferHigh[pos]) {
                  h = i;
                  break;
              }
            }
            for (i = pos+nBars; i < Bars; i++) {
              if (Close < MapBufferLow[pos]) {
                  l = i;
                  break;
              }
            }
            MapBufferHighArrow[pos] = EMPTY_VALUE;
            MapBufferLowArrow[pos] = EMPTY_VALUE;
            if (h>l) {
              //l is closer than h, hide high line
              MapBufferHigh[pos] = EMPTY_VALUE;
              if (show_l == false) {
                  show_l = true;
                  if (ShowArrow) MapBufferLowArrow[pos] = MapBufferLow[pos];
              }
              show_h = false;
            } else if (h<l) {
              //h is closer than l, hide low line
              MapBufferLow[pos] = EMPTY_VALUE;
              if (show_h == false) {
                  show_h = true;
                  if (ShowArrow) MapBufferHighArrow[pos] = MapBufferHigh[pos];
              }
              show_l = false;
            } else {
              //h equals to l
              MapBufferHigh[pos] = EMPTY_VALUE;
              MapBufferLow[pos] = EMPTY_VALUE;
              show_h = false;
              show_l = false;             
            }
        }
              pos--;
    }

  if(ExtCountedBars<1) {
      for(i=1;i<nBars;i++) {
        MapBufferHigh[Bars-i]=EMPTY_VALUE;
        MapBufferLow[Bars-i]=EMPTY_VALUE;
        MapBufferHighArrow[Bars-i]=EMPTY_VALUE;
        MapBufferLowArrow[Bars-i]=EMPTY_VALUE;
      }
  }
//---- done
  return(0);
  }
 


附件附件:

您所在的用户组无法下载或查看附件

 

[em03]谢谢分享
一年又一年
 

回复:搜罗一个修改后的飞狐的指标,有图

引入出错??
for (i = pos+nBars; i < Bars; i++) {
              if (Close>MapBufferHigh[pos]) {
                  h = i;
                  break;
              }
            }
            for (i = pos+nBars; i < Bars; i++) {
              if (Close < MapBufferLow[pos]) {
                  l = i;
                  break;
              }

'>' - series array has no left square bracket. zero shift assumed    D:\my\MetaTrader 4\experts\scripts\hhll.mq4 (106, 24)
 
1  /  1  页   1 跳转

版权所有 外汇通  Forex.Com.Cn  Sitemap

Powered by Discuz!NT 2.0.1214    Copyright © 2001-2008 Comsenz Inc. 京ICP证020368号
返顶部