指标: JFATL

 

JFATL:

此指标是 FATL 数字滤波器和 JMA 移动均线的组合。

ColorJFATL 指标

作者: Nikolay Kositsin

 

您好、

除了这个版本,还有其他 MT4 版本吗?

谢谢。

 

试试这个简单实用的补丁。

/*
 * 将 SmoothAlgorithms.mqh 文件
 * 放到 terminal_data_folder\MQL5\Include
 */
//+------------------------------------------------------------------+
//|JFatl.mq4
//|版权所有 © 2010, Nikolay Kositsin |
//|哈巴罗夫斯克, farria@mail.redcom.ru | | 
//+------------------------------------------------------------------+
#property copyright "2010,   Nikolay Kositsin"
#property link      "farria@mail.redcom.ru"
#property version   "1.00"
//---- 在主窗口中绘制指示器
#property indicator_chart_window
//---- 一个缓冲区用于计算和绘制指示器
#property indicator_buffers 1
//---- 只使用一个地块
#property indicator_plots   1
//---- 将指标绘制成直线
#property  indicator_type1   DRAW_LINE
//---- 蓝色用作指示线的颜色
#property  indicator_color1  Blue
//---- 指示线是一条连续曲线
#property  indicator_style1  STYLE_SOLID
//---- 指标行宽度等于 2
#property  indicator_width1  2
//---- 显示指标行标签
#property  indicator_label1  "JFATL"
#property strict
//+-----------------------------------+
//| 指标输入参数
//+-----------------------------------+
enum Applied_price_ //常数类型
  {
   PRICE_CLOSE_ = 1,     //PRICE_CLOSE
   PRICE_OPEN_,          //PRICE_OPEN
   PRICE_HIGH_,          //价格_高
   PRICE_LOW_,           //PRICE_LOW
   PRICE_MEDIAN_,        //PRICE_MEDIAN
   PRICE_TYPICAL_,       //price_typical
   PRICE_WEIGHTED_,      //价格加权
   PRICE_SIMPLE,         //PRICE_SIMPLE
   PRICE_QUARTER_,       //price_quarter_
   PRICE_TRENDFOLLOW0_,  //price_trendfollow0_
   PRICE_TRENDFOLLOW1_   //price_trendfollow1_
  };
input int JMALength_=5;  // JMA 平滑处理的深度 
input int JMAPhase_=100; // JMA 平滑参数、
                         //在 -100 ... 范围内发生变化。+100
//影响过渡过程的质量;
input Applied_price_ IPC=PRICE_CLOSE_; // 价格常数
/* 用于计算指标(1-关闭,2-打开,3-高,4-低,
 5-平均,6-典型,7-加权,8-简约,9-季度,10-跟踪,11-0.5 *跟踪。)*/
input int FATLShift = 0; // 以小节为单位的 FATL 水平移动
input int PriceShift=0;  // 以点为单位的 FATL 垂直移动
//---+
//---- 变量的声明和初始化,用于存储计算出的条数
int FATLPeriod=39;

//---- 动态数组的声明 
//---- 将用作指示器缓冲区
double ExtLineBuffer[];

int start,fstart,FATLSize;
double dPriceShift;
//+-----------------------------------------------------------+ 
// 数字滤波器系数的初始化
//+-----------------------------------------------------------+ 
double FATLTable[]=
  {
   +0.4360409450, +0.3658689069, +0.2460452079, +0.1104506886,
   -0.0054034585, -0.0760367731, -0.0933058722, -0.0670110374,
   -0.0190795053, +0.0259609206, +0.0502044896, +0.0477818607,
   +0.0249252327, -0.0047706151, -0.0272432537, -0.0338917071,
   -0.0244141482, -0.0055774838, +0.0128149838, +0.0226522218,
   +0.0208778257, +0.0100299086, -0.0036771622, -0.0136744850,
   -0.0160483392, -0.0108597376, -0.0016060704, +0.0069480557,
   +0.0110573605, +0.0095711419, +0.0040444064, -0.0023824623,
   -0.0067093714, -0.0072003400, -0.0047717710, +0.0005541115,
   +0.0007860160, +0.0130129076, +0.0040364019
  };
//+------------------------------------------------------------------+
//| iPriceSeries() 函数说明|
//| iPriceSeriesAlert() 函数说明
//| CJJMA 类说明|
//+------------------------------------------------------------------+ 
#include <SmoothAlgorithms.mqh>  
//+------------------------------------------------------------------+
//| 自定义指示器初始化函数
//+------------------------------------------------------------------+ 
void OnInit()
  {
//---- 设置 ExtLineBuffer 动态数组作为指示器缓冲区
   SetIndexBuffer(0,ExtLineBuffer,INDICATOR_DATA);
//---- 通过 FATLShift 水平移动指示器
   PlotIndexSetInteger(0,PLOT_SHIFT,FATLShift);
//---- 变量初始化 
   FATLSize=ArraySize(FATLTable);
   start=FATLSize+30;
//---- 执行指标绘制起点的移动
   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,start);
//---- 初始化指标短名变量
   string shortname;
   StringConcatenate(shortname,"JFATL(",JMALength_," ,",JMAPhase_,")");
//---- 创建在 DataWindow 中显示的标签
   PlotIndexSetString(0,PLOT_LABEL,shortname);
//---- 创建名称,在单独的子窗口和工具提示中显示
   IndicatorSetString(INDICATOR_SHORTNAME,shortname);
//---- 确定指标值显示的准确性
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits+1);
//---- 限制为指标绘制空值
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
//---- 垂直移位的初始化
   dPriceShift=_Point*PriceShift;
//---- SmoothAlgorithms.mqh 文件中 CJJMA 类变量的声明
   CJJMA JMA;
//---- 针对不可接受的外部变量值设置警报
   JMA.JJMALengthCheck("Length_", JMALength_);
   JMA.JJMAPhaseCheck("Phase_", JMAPhase_);
//----
  }
//+------------------------------------------------------------------+
//| 自定义指标迭代函数|
//+------------------------------------------------------------------+
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<start)
      return(0);
  ArraySetAsSeries(ExtLineBuffer, false);

//---- 本地变量的声明 
   int first,bar;
   double jfatl,FATL;

//---- 计算条形图重新计算循环的 "第一个 "起始索引
   if(prev_calculated>rates_total || prev_calculated<=0) // 检查指标是否首次开始计算
     {
      first=FATLPeriod-1; // 计算所有条形图的起始指数
      fstart=first;
     }
   else first=prev_calculated-1; // 计算新条形的起始指数

//---- SmoothAlgorithms.mqh 文件中 CJJMA 类变量的声明
   static CJJMA JMA;

//---- 主指标计算循环
   for(bar=first; bar<rates_total; bar++)
     {
      //---- FATL 滤波器公式
      FATL=0.0;
      for(int iii=0; iii<FATLSize; iii++)
         FATL+=FATLTable[iii]*PriceSeries(IPC,rates_total-(bar-iii)-1,open,low,high,close);

      //---- 一次调用 JJMASeries 函数。 
      //---- 相位和长度参数不会在每个条形图上更改(Din = 0)。 
      jfatl=JMA.JJMASeries(fstart,prev_calculated,rates_total,0,JMAPhase_,JMALength_,FATL,bar,false);

      //---- 根据获取的 FATL 值初始化指示器缓冲区单元格
      ExtLineBuffer[bar]=jfatl+dPriceShift;
     }
//---- 
   return(rates_total);
  }
//+------------------------------------------------------------------+