//±-----------------------------------------------------------------+
//| fbi.mq5 |
//±-----------------------------------------------------------------+
#property copyright “Copyright 2022, icepsyche”
#property link “https://www.mql5.com”
#property version “1.00”

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots 1
//— plot ZigZag
#property indicator_label1 “fZigZag”
#property indicator_type1 DRAW_SECTION
#property indicator_color1 clrRed
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//— input parameters
input int InpDepth =5; // Depth
//— indicator buffers
double ZigZagBuffer[]; // main buffer
double HighMapBuffer[]; // ZigZag high extremes (peaks)
double LowMapBuffer[]; // ZigZag low extremes (bottoms)

int ExtRecalc=3; // number of last extremes for recalculation

enum EnSearchMode
{
Extremum=0, // searching for the first extremum
Peak=1, // searching for the next ZigZag peak
Bottom=-1 // searching for the next ZigZag bottom
};
//±-----------------------------------------------------------------+
//| Custom indicator initialization function |
//±-----------------------------------------------------------------+
void OnInit()
{
//— indicator buffers mapping
SetIndexBuffer(0,ZigZagBuffer,INDICATOR_DATA);
SetIndexBuffer(1,HighMapBuffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(2,LowMapBuffer,INDICATOR_CALCULATIONS);
//— set short name and digits
string short_name=StringFormat(“ZigZag(%d)”,InpDepth);
IndicatorSetString(INDICATOR_SHORTNAME,short_name);
PlotIndexSetString(0,PLOT_LABEL,short_name);
IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//— set an empty value
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
}
//±-----------------------------------------------------------------+
//| ZigZag calculation |
//±-----------------------------------------------------------------+
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[])
{
if(rates_total<100)
return(0);
//—
int i=0;
int start=0,extreme_counter=0,extreme_search=Extremum;
int shift=0,last_high_pos=0,last_low_pos=0;
double res=0;
double curlow=0,curhigh=0,last_high=0,last_low=0;
//— initializing
if(prev_calculated==0)
{
ArrayInitialize(ZigZagBuffer,0.0);
ArrayInitialize(HighMapBuffer,0.0);
ArrayInitialize(LowMapBuffer,0.0);
start=InpDepth;
}

//— ZigZag was already calculated before
if(prev_calculated>0)
{
i=rates_total-1;
//— searching for the third extremum from the last uncompleted bar
while(extreme_counter<ExtRecalc && i>rates_total-100)
{
res=ZigZagBuffer[i];
if(res!=0.0)
extreme_counter++;
i–;
}
i++;
start=i;

  //--- what type of exremum we search forif(LowMapBuffer[i]!=0.0){curlow=LowMapBuffer[i];extreme_search=Peak;}else{curhigh=HighMapBuffer[i];extreme_search=Bottom;}//--- clear indicator valuesfor(i=start+1; i<rates_total && !IsStopped(); i++){ZigZagBuffer[i] =0.0;LowMapBuffer[i] =0.0;HighMapBuffer[i]=0.0;}}

//— searching for high and low extremes
for(shift=start+1; shift<rates_total-1 && !IsStopped(); shift++)
{
if(low[shift] <= low[shift+1])
{
if(Lowest(high,low,InpDepth-2,shift))
{
LowMapBuffer[shift] = low[shift];
}
else
{
LowMapBuffer[shift] = 0.0;
}
}

  if(high[shift] >= high[shift+1]){if(Highest(high,low,InpDepth-2,shift)){HighMapBuffer[shift] = high[shift];}else{HighMapBuffer[shift] = 0.0;}}}

//— set last values
if(extreme_search==0) // undefined values
{
last_low=0.0;
last_high=0.0;
}
else
{
last_low=curlow;
last_high=curhigh;
}

//— final selection of extreme points for ZigZag
for(shift=start; shift<rates_total && !IsStopped(); shift++)
{
res=0.0;
switch(extreme_search)
{
case Extremum:
if(last_low0.0 && last_high0.0)
{
if(HighMapBuffer[shift]!=0)
{
last_high=high[shift];
last_high_pos=shift;
extreme_search=Bottom;
ZigZagBuffer[shift]=last_high;
res=1;
}
if(LowMapBuffer[shift]!=0.0)
{
last_low=low[shift];
last_low_pos=shift;
extreme_search=Peak;
ZigZagBuffer[shift]=last_low;
res=1;
}
}
break;
case Peak:
if(LowMapBuffer[shift]!=0.0 && LowMapBuffer[shift]<last_low && HighMapBuffer[shift]==0.0)
{
ZigZagBuffer[last_low_pos]=0.0;
last_low_pos=shift;
last_low=LowMapBuffer[shift];
ZigZagBuffer[shift]=last_low;
res=1;
}
if(HighMapBuffer[shift]!=0.0 && LowMapBuffer[shift]==0.0)
{
last_high=HighMapBuffer[shift];
last_high_pos=shift;
ZigZagBuffer[shift]=last_high;
extreme_search=Bottom;
res=1;
}
break;
case Bottom:
if(HighMapBuffer[shift]!=0.0 && HighMapBuffer[shift]>last_high && LowMapBuffer[shift]==0.0)
{
ZigZagBuffer[last_high_pos]=0.0;
last_high_pos=shift;
last_high=HighMapBuffer[shift];
ZigZagBuffer[shift]=last_high;
}
if(LowMapBuffer[shift]!=0.0 && HighMapBuffer[shift]==0.0)
{
last_low=LowMapBuffer[shift];
last_low_pos=shift;
ZigZagBuffer[shift]=last_low;
extreme_search=Peak;
}
break;
default:
return(rates_total);
}
}

//— return value of prev_calculated for next call
return(rates_total);
}
//±-----------------------------------------------------------------+
//| looking for peak |
//±-----------------------------------------------------------------+
bool Highest(const double &hh[],const double &ll[],const int depth,const int start)
{
bool bb = false;
double llv = ll[start];
double hhv = hh[start];
int i = start-1;
while(i >= 0 && !bb)
{
if(hhv <= hh[i])
{
break;
}
else
{
if(start-i > depth && ll[i] <= llv)
{
bb = true;
break;
}
llv = llv <= ll[i] ? llv : ll[i];
}
i–;
}
return(bb);
}
//±-----------------------------------------------------------------+
//| looking for bottom |
//±-----------------------------------------------------------------+
bool Lowest(const double &hh[],const double &ll[],const int depth,const int start)
{
bool bb = false;
double llv = ll[start];
double hhv = hh[start];
int i = start-1;
while(i >= 0 && !bb)
{
if(llv >= ll[i])
{
break;
}
else
{
if(start-i > depth && hh[i] >= hhv)
{
bb = true;
break;
}
hhv = hhv >= hh[i] ? hhv : hh[i];
}
i–;
}
return(bb);
}
//±-----------------------------------------------------------------+

笔形式的之字形高低点指标(MT5)相关推荐

  1. java 计算股票高低点_[转载]股市中常用的一些计算高低点的计算方法

    朋友们观看股评文章时,常常发现那些专家或准专家发出股价在上涨到某某价位会遇到阻力或股价在下跌途中在某一价位会遇到有效支撑的判断,而股价也真的会在这一价位附近掉头向下(上涨途中)或横盘盘整.或下跌途中的 ...

  2. 机械革命笔机本全套4K高清壁纸原系统提取

    ** 机械革命笔机本全套4K高清壁纸原系统提取** -------------------------------------------------------------------------点 ...

  3. matlab布林算法代码,MATLAB量化交易策略源码分享之 布林通道+高低点

    策略原理: 通过布林带以及突破后的高低点的形成产生交易信号 采取跟踪止损出场 回测曲线: 2017-2-27 10:09:43 上传 下载附件 (65.41 KB) 策略代码: function  S ...

  4. SkeyeARS 全景AR增强监视系统实现高低点摄像机关联显示(一)

    SkeyeARS 全景AR增强监视系统实现高低点摄像机关联显示(一) 1.写在前面 在很多全景监控的场景中,很多时候需要将全景与点位关联起来. 并且,对于我们的全景AR增强系统,还要将点位的位置与全景 ...

  5. java 计算股票高低点,怎样计算股票次日的高低点

    在超短线操作(次日套利)中,对目标个股次日的买入卖出价的测算是锁定利润的关键步骤,目前已知的测算方法中,比较有效的是利用5分钟.15分钟.30分钟以及60分钟K线中可信度比较高的技术指标,如KDJ是否 ...

  6. ipad画画什么触控笔最好?适合Ipad高性价比电容笔推荐

    越来越多的人开始使用平板而不仅仅是移动电话.不管是工作还是学习,大屏幕可以使图像更加清晰.无论现在还是将来,平板电脑都将是主要的市场.如果搭配上一支使用起来很方便的电容笔,可以极大地提高使用者的工作效 ...

  7. 用手机画画什么触控笔比较好?性价比高的触控笔推荐

    现在,很多人喜欢用ipad来记录,或者随便画画.很多ipad的使用者,都非常看重ipad的实用性,他们发现有不少人拿着ipad做记录,就想着要把ipad的性能提升到最大.其实要是仅仅用电容笔来记笔记的 ...

  8. 上市公司女性高管指标 1999-2020年(内附详细指标说明及代码)

    1.数据来源:在分享文件中附带 2.时间跨度:1999-2020年 3.区域范围:全国 4.指标说明: 详细指标说明以及代码附在分享文件中 计算参考文献: 杜兴强, 冯文滔. 女性高管.制度环境与慈善 ...

  9. 以对象的形式动态获取宽高

    2019独角兽企业重金招聘Python工程师标准>>> 1. 当页面的宽度使用的是百分比时,或者父元素的宽度未设置,子元素的宽度随着父元素的宽度变化而变化,想动态获取div的宽度,使 ...

最新文章

  1. MacOS使用Charles抓去HTTPS数据
  2. 在Opendaylight中karaf启动的时候自动安装feature
  3. Spring: (一) -- 春雨润物之 核心IOC
  4. BZOJ 2818GCD
  5. datagridview 绑定list 不能刷新界面_人人都可写代码-H5零基础编程-发布活动界面实操07...
  6. nginx 中location和root,你确定真的明白他们关系?
  7. Html之实例练习(轮播图片、放大镜效果、面板拖动)
  8. location.reload() 和 location.replace()的区别和应用
  9. Pytorch——DataLoader(批训练)
  10. sudo修改文件夹名字_用 Python 高效智能管理文件夹
  11. 操作系统概念第三章部分作业题答案
  12. 第三届CCF计算机职业资格认证考试题解(C++)
  13. Exchange 2003 设计与体系结构
  14. iS3 岩石隧道数据准备手册
  15. spring boot + vue 前后端下载文件文件
  16. 麻将判断几步入听算法
  17. javaGUl编程设计(大学生项目)
  18. Python学习笔记002-安装SQL Server2016(和操作系统般配^-^)
  19. 微信JSSDK多图片上传
  20. NOI 09:奇数求和

热门文章

  1. java版我的世界有溺尸_我的世界溺尸怎么找
  2. dwr框架查看外放方法_轻松看懂建筑图纸符号!这样简单高效的方法你一定要知道...
  3. WINDOWS API——OPENCLIPBOARD——剪切板
  4. 免费学习编程的10个好工具!
  5. 不要等到双十一,几何画板带回家!
  6. 图像标记的认识加使用
  7. 开源社邀请您参加2022 第四届天津前端开发者大会
  8. python系统设计与实现_毕业设计5:基于MicroPython的智能火灾报警器系统的设计与实现...
  9. 九年级计算机网页知识教案,九年级信息技术教案
  10. 前景理论和期望效用理论