该 GetExtremums() 函数设计用来标识整个给定历史周期的极值。搜索算法类似 FastZZ 指标使用的, 并且仅使用一个参数 - 最小价格变化 - 来标识一个极值。
int GetExtremums(double range, //最小价格变化 MqlRates &rates[], //历史行情数组 dextremum &ge[], //返回极值数组 int total=0) //极值需求数量或零(所有极值)参数:
以下结构用于极值描述。
struct dextremum //极值描述 { int type; //1 - 峰值, -1 - 谷底 datetime time; double value; };
使用 GetExtremums() 的例子。
#include <GetExtremums.mqh> //---- void OnStart() { MqlRates rt[]; dextremum zz[]; CopyRates(_Symbol,_Period,TimeCurrent(),100,rt); //第一个变种 - 得到 10 个极值 int cnt=GetExtremums(100*_Point,rt,zz,10); for(int i=0; i<cnt; i++) Print(i,") ",zz[i].time," >> ",zz[i].type==1?"峰值":"谷底","=",zz[i].value); //第二个变种 - 得到所有极值 cnt=GetExtremums(100*_Point,rt,zz); Print("发现 ",cnt," 极值"); } //----
由MetaQuotes Ltd译自俄语
原代码: /ru/code/1052