//+------------------------------------------------------------------------+ //| JFatlAcceleration_HTF.mq5 | //| Copyright �2010, Nikolay Kositsin | //| Khabarovsk, farria@mail.redcom.ru | //+------------------------------------------------------------------------+ //| 放置 SmoothAlgorithms.mqh 文件 | //| 于目录: 客户端数据文件夹\MQL5\Include | //| 且同样放置 ColorJFatlAcceleration.mq5 文件于目录: | //| 客户端数据文件夹\MQL5\Indicators | //+------------------------------------------------------------------------+ #property copyright "Copyright �2010, Nikolay Kositsin" #property link "farria@mail.redcom.ru" //---- 指标版本 #property version "1.00" //---- 绘制指标于主窗口 #property indicator_chart_window //---- 指标缓存区数量 4 #property indicator_buffers 4 //---- 使用 4 个绘图通道 #property indicator_plots 4 //+----------------------------------------------+ //| Declaration of constants | //+----------------------------------------------+ #define RESET 0 // 常量用于将指标重新计算命令反馈到终端 #define INDICATOR_NAME "JFatl Acceleration" // 指标名称常量 //+----------------------------------------------+ //| Bearish indicator drawing parameters | //+----------------------------------------------+ //---- 画指标 1 作为箭头 #property indicator_type1 DRAW_ARROW //---- 红色作为指标线的颜色 #property indicator_color1 Red //---- 指标 1 线宽度 4 #property indicator_width1 4 //---- 显示指标标签 #property indicator_label1 INDICATOR_NAME" Sell Max" //+----------------------------------------------+ //| Bullish indicator drawing parameters | //+----------------------------------------------+ //---- 指标 2 绘制为线 #property indicator_type2 DRAW_ARROW //---- 石灰色作为指标线的颜色 #property indicator_color2 Lime //---- 指标 2 线宽度 4 #property indicator_width2 4 //---- 显示指标标签 #property indicator_label2 INDICATOR_NAME" Buy Max" //+----------------------------------------------+ //| Bearish indicator drawing parameters | //+----------------------------------------------+ //---- 画指标 3 作为箭头 #property indicator_type3 DRAW_ARROW //---- 品红色作为指标的颜色 #property indicator_color3 Magenta //---- 指标 3 线宽度 4 #property indicator_width3 4 //---- 显示指标标签 #property indicator_label3 INDICATOR_NAME" Sell Min" //+----------------------------------------------+ //| Bullish indicator drawing parameters | //+----------------------------------------------+ //---- 画指标 4 作为箭头 #property indicator_type4 DRAW_ARROW //---- 黄色作为指标牛势线的颜色 #property indicator_color4 Yellow //---- 指标 4 线宽度 4 #property indicator_width4 4 //---- 显示指标标签 #property indicator_label4 INDICATOR_NAME" Buy Min" //+----------------------------------------------+ //| Declaration of enumerations | //+----------------------------------------------+ enum Smooth_Method { MODE_SMA_, // SMA MODE_EMA_, // EMA MODE_SMMA_, // SMMA MODE_LWMA_, // LWMA MODE_JJMA, // JJMA MODE_JurX, // JurX MODE_ParMA, // ParMA MODE_T3, // T3 MODE_VIDYA, // VIDYA MODE_AMA, // AMA }; enum Applied_price_ // 类型常量 { PRICE_CLOSE_ = 1, // PRICE_CLOSE PRICE_OPEN_, // PRICE_OPEN PRICE_HIGH_, // PRICE_HIGH PRICE_LOW_, // PRICE_LOW PRICE_MEDIAN_, // PRICE_MEDIAN PRICE_TYPICAL_, // PRICE_TYPICAL PRICE_WEIGHTED_, // PRICE_WEIGHTED PRICE_SIMPLE, // PRICE_SIMPLE PRICE_QUARTER_, // PRICE_QUARTER_ PRICE_TRENDFOLLOW0_, // PRICE_TRENDFOLLOW0_ PRICE_TRENDFOLLOW1_ // PRICE_TRENDFOLLOW1_ }; //+-------------------------------------+ //| Indicator input parameters | //+-------------------------------------+ input uint LableShift=100; // 标垂直位移 input uint AlertCount=0; // 提交报警次数 input uint SignalBar=1; // 信号柱线索引, 0 是当前柱线 input ENUM_TIMEFRAMES TimeFrame=PERIOD_H4; // 图表周期 input int Length_=8; // Fatl 平滑的 JMA 周期 input int Phase_=100; // Fatl 平滑的 JMA 参数 [-100...+100] input int SpeedPeriod=1; // 速率周期 input int AccelerationPeriod=1; // 加速周期 input int Smooth=2; // 指标 JMA 平滑深度 input int SmPhase=100; // 指标 JMA 平滑参数 [-100...+100] input Applied_price_ IPC=PRICE_CLOSE_; // 适用价格 input int FATLShift=0; // 指标的水平位移柱线数 //---- 声明动态数组 //---- 用于将来的指标缓存区 double BuyMaxBuffer[],SellMaxBuffer[]; double BuyMinBuffer[],SellMinBuffer[]; //---- 声明变量用于保存指标初始化结果 bool Init; //---- 声明字符串变量 string Symbol_,Word; //----声明数据计算开始的整数变量 int min_rates_total; //---- 声明整数变量保存指标句柄 int JFAccel_Handle; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { Init=true; //---- 检查图表周期正确与否 if(TimeFramerates_total || prev_calculated<=0)// 检查指标计算的第一个起始柱线 { limit=rates_total-min_rates_total-1; // 所有柱线的起始计算索引 LastCountBar=rates_total; } else limit=int(LastCountBar)+rates_total-prev_calculated; // 新柱线的起始计算索引 //--- 元素作为时间序列索引 ArraySetAsSeries(time,true); ArraySetAsSeries(high,true); ArraySetAsSeries(low,true); //--- 指标计算主循环 for(bar=limit; bar>=0 && !IsStopped(); bar--) { //--- 清空指标缓存区内容 BuyMaxBuffer[bar]=0.0; SellMaxBuffer[bar]=0.0; BuyMinBuffer[bar]=0.0; SellMinBuffer[bar]=0.0; //--- 复制新出现数据至 JFAccelTime[] 数组 if(CopyTime(Symbol_,TimeFrame,time[bar],1,JFAccelTime)<=0) return(RESET); if(time[bar]>=JFAccelTime[0] && time[bar+1]JFAccel[1]) SellMaxBuffer[bar]=high[bar]+LableShift*_Point; else SellMinBuffer[bar]=high[bar]+LableShift*_Point; } else { if(JFAccel[0]>JFAccel[1]) BuyMinBuffer[bar]=low[bar]-LableShift*_Point; else BuyMaxBuffer[bar]=low[bar]-LableShift*_Point; } } } //--- 警报计算清零 if(rates_total!=prev_calculated) { UpCount=0; DnCount=0; UpCount_=0; DnCount_=0; } //--- 提交一个买警报 if(UpCount