1评论

0收藏

自适应移动平均指标

avatar 追星 | 122 人阅读 | 1 人评论 | 2024-04-23

自适应移动平均指标
自适应移动平均指标 (Adaptive Moving Average,AMA) 技术指标用于构造对价格序列噪声具有低灵敏度的移动平均,并且其特征在于趋势检测的最小滞后。这一指标是由Perry Kaufman在其著作《更聪明的交易》中开发和描述的。
不同的价格序列平滑算法的缺点之一是,意外的价格跳跃会导致虚假趋势信号的出现。另一方面,平滑导致关于趋势停止或变化的信号不可避免地滞后。开发这一指标就是为了消除这两个缺点。


参数
iAMA() 函数用于创建指标的句柄:
返回自适应移动平均指标的句柄。只有一个缓冲区。
int  iAMA(   string              symbol,             // symbol name   ENUM_TIMEFRAMES     period,             // period   int                 ama_period,         // AMA period   int                 fast_ma_period,     // fast Moving Average period   int                 slow_ma_period,     // slow Moving Average period   int                 ama_shift,          // horizontal shift of the indicator   ENUM_APPLIED_PRICE  applied_price       // price type or handle   );
symbol
[in] 其数据将用于计算指标的金融工具的交易品种名称。NULL表示当前交易品种。
period
[in] 周期值可以是ENUM_TIMEFRAMES枚举值之一,0表示当前时间框架。
ama_period
[in]  效率计算周期数。
fast_ma_period
[in] 市场快速波动时计算平滑率的快速周期数。
slow_ma_period
[in] 没有趋势时计算平滑率的慢速周期数。
ama_shift
[in] 指标相对于价格图表的偏移。
applied_price
[in]  应用的价格,可以是 ENUM_APPLIED_PRICE 价格常数中的任一个或者是另一个指标的句柄。
返回指定技术指标的句柄,如果失败,则返回 INVALID_HANDLE。 要从未使用的指标中释放计算机内存,请使用指标句柄传递到 IndicatorRelease()

在EA中声明输入参数和全局变量以创建指标:
//+------------------------------------------------------------------+//|                                                 TestTrendAMA.mq5 |//|                                  Copyright 2023, MetaQuotes Ltd. |//|                                             https://www.mql5.com |//+------------------------------------------------------------------+#property copyright "Copyright 2023, MetaQuotes Ltd."#property link      "https://www.mql5.com"#property version   "1.00"//--- enumsenum ENUM_LINE_STATE  {   LINE_STATE_NONE,        // Undefined state   LINE_STATE_UP,          // Upward   LINE_STATE_DOWN,        // Downward   LINE_STATE_TURN_UP,     // Upward reversal   LINE_STATE_TURN_DOWN,   // Downward reversal   LINE_STATE_STOP_UP,     // Upward stop   LINE_STATE_STOP_DOWN,   // Downward stop   LINE_STATE_ABOVE,       // Above value   LINE_STATE_UNDER,       // Below value   LINE_STATE_CROSS_UP,    // Crossing value upwards   LINE_STATE_CROSS_DOWN,  // Crossing value downwards   LINE_STATE_TOUCH_BELOW, // Touching value from below    LINE_STATE_TOUCH_ABOVE, // Touch value from above   LINE_STATE_EQUALS,      // Equal to value  };//--- input parametersinput uint                 InpPeriod      =  9;             /* Period         */input uint                 InpPeriodFast  =  2;             /* Fast EMA Period*/input uint                 InpPeriodSlow  =  30;            /* Slow EMA Period*/input int                  InpShift       =  0;             /* AMA Shift      */input ENUM_APPLIED_PRICE   InpPrice       =  PRICE_CLOSE;   /* Applied Price  *///--- global variablesint      handle=INVALID_HANDLE;  // Indicator handleint      period=0;               // AMA calculation periodint      period_fast=0;          // Fast EMA calculation periodint      period_slow=0;          // Slow EMA calculation periodint      ind_digits=0;           // Number of decimal places in the indicator valuesstring   ind_title;              // Indicator description
创建 ENUM_LINE_STATE 枚举是为了简化获取指标线的状态,即其相对于另一个指标或任何级别的线的形状和位置。
在振荡指标文章中的ATR指标参数部分可以查找有关枚举的更多信息。
在EA中使用仪表板时,声明全局变量,包括面板类文件:
//+------------------------------------------------------------------+//|                                                 TestTrendAMA.mq5 |//|                                  Copyright 2023, MetaQuotes Ltd. |//|                                             https://www.mql5.com |//+------------------------------------------------------------------+#property copyright "Copyright 2023, MetaQuotes Ltd."#property link      "https://www.mql5.com"#property version   "1.00"//--- includes#include <Dashboard\Dashboard.mqh>//--- enumsenum ENUM_LINE_STATE  {   LINE_STATE_NONE,        // Undefined state   LINE_STATE_UP,          // Upward   LINE_STATE_DOWN,        // Downward   LINE_STATE_TURN_UP,     // Upward reversal   LINE_STATE_TURN_DOWN,   // Downward reversal   LINE_STATE_STOP_UP,     // Upward stop   LINE_STATE_STOP_DOWN,   // Downward stop   LINE_STATE_ABOVE,       // Above value   LINE_STATE_UNDER,       // Below value   LINE_STATE_CROSS_UP,    // Crossing value upwards   LINE_STATE_CROSS_DOWN,  // Crossing value downwards   LINE_STATE_TOUCH_BELOW, // Touching value from below    LINE_STATE_TOUCH_ABOVE, // Touch value from above   LINE_STATE_EQUALS,      // Equal to value  };//--- input parametersinput uint                 InpPeriod      =  9;             /* Period         */input uint                 InpPeriodFast  =  2;             /* Fast EMA Period*/input uint                 InpPeriodSlow  =  30;            /* Slow EMA Period*/input int                  InpShift       =  0;             /* AMA Shift      */input ENUM_APPLIED_PRICE   InpPrice       =  PRICE_CLOSE;   /* Applied Price  *///--- global variablesint      handle=INVALID_HANDLE;  // Indicator handleint      period=0;               // AMA calculation periodint      period_fast=0;          // Fast EMA calculation periodint      period_slow=0;          // Slow EMA calculation periodint      ind_digits=0;           // Number of decimal places in the indicator valuesstring   ind_title;              // Indicator description//--- variables for the panelint      mouse_bar_index;        // Index of the bar the data is taken fromCDashboard *panel=NULL;          // Pointer to the panel object

""
还没有人打赏,支持一下

评论|共 1 个

兔斯基_5912

发表于 2024-4-23 16:54:58 | 显示全部楼层

非常棒和详细

您需要登录后才可以回帖 登录 | 注册 微信登录

EA之家评论守则