指标: J. F. Ehlers 重心

 

J. F. Ehlers 重心:

重心振荡器,由 John Ehlers 开发并发表于 "Stocks & Commodities (股票 & 期货)" 杂志 (2002 五月)。

图例.1 重心指标

作者: Nikolay Kositsin

 
很有用!......我想知道换色的标准。
 

您好、

这个振荡器很不错,但我用起来有问题。

根据最后一根蜡烛计算出的信号线 末端没有显示出来,因此当前时间总是显示红色。当我重置振荡器时,它会在信号线末端显示一段时间的良好值,但随后又切换回红色(即使它必须显示绿色)。

我该如何解决这个问题?

我试过重新调试,但没有用。

谢谢、

InfiniteDesign

 
在他看来, 这个指标 可以 mehor 符号 和时间框架一起使用。
指标 参数 最佳值是 多少
 

非常非常感谢这个伟大的指标。

我发现以前的版本和新版本一样有趣、有用,甚至更有用。

能不能把旧版本也移植到 mq5 上?如果可以,我会非常感激。


谢谢

 
这个指标是非确定性的。在不同的时间两次询问相同的数据点,你会得到不同的答案。越接近当前时间,漂移越大。不一致性可高达 3.7 x 10^-04。
 
InfiniteDesign:

您好、

这个振荡器很不错,但我用起来有问题。

根据最后一根蜡烛计算出的信号线 末端没有显示出来,因此当前时间总是显示红色。当我重置振荡器时,它会在信号线末端显示一段时间的良好值,但随后又切换回红色(即使它必须显示绿色)。

我该如何解决这个问题?

我试过重新调试,但没有用。

谢谢、

InfiniteDesign

我也有同样的问题...
 

我试图用该指标创建一个信号,但无法...

有什么帮助吗?


//+------------------------------------------------------------------+
//|COG.mqh | |
//|布鲁诺-皮奥
//|http://www.mql5.com ||
//+------------------------------------------------------------------+
#property copyright "Bruno Pio"
#property link      "http://www.mql5.com"
#property version   "1.00"
#include "..\ExpertSignal.mqh"   // CExpertSignal 位于文件 ExpertSignal 中。
#property tester_indicator "CenterOfGravity.ex5"
// 向导描述开始
//+------------------------------------------------------------------+
//| 类的描述|
//| Title=重心信号|
//| 类型=高级信号|
//| Name=My_COG|
//| ShortName=CG|
//| Class=COG|
//| Page=不需要|
//| 参数=Period_,int,10,指标平均周期
//| 参数=SmoothPeriod,int,3,信号线平滑周期
//| 参数=MA_Method_,ENUM_MA_METHOD,MODE_EMA,信号方法
//| Parameter=AppliedPrice,int,1,Price constant | 参数=应用价格,int,1,价格常数
//+------------------------------------------------------------------+
// 向导描述 结束
//+------------------------------------------------------------------+
//||
//+------------------------------------------------------------------+
class COG : public CExpertSignal
  {
private:
CiCustom             m_COG;               // 指标作为一个对象
//--- 可配置的模块参数
   int               m_Period_;           // 指标平均周期
   int               m_SmoothPeriod;      // 信号线平滑周期 
   ENUM_MA_METHOD    m_MA_Method_;        // 信号线平均法
   int               m_AppliedPrice;      // 价格常数
public:
                     COG(void);
                    ~COG(void);
//--- 检查输入数据的正确性
   bool              ValidationSettings();
//-- 为信号模块创建指标和时间序列
   bool              InitIndicators(CIndicators *indicators);
//--- 访问指标数据
   double            CG(const int index)                 const { return(m_COG.GetData(0,index)); }
   double            Signal(const int index)             const { return(m_COG.GetData(1,index)); }   
//--- 检查买入和卖出条件
   virtual int       LongCondition();
   virtual int       ShortCondition();
//--- 设置方法
   void              Period_(int value)               { m_Period_=value;        }
   void              SmoothPeriod(int value)          { m_SmoothPeriod=value;   }
   void              MA_Method_(ENUM_MA_METHOD value) { m_MA_Method_=value;     }
   void              AppliedPrice(int value)          { m_AppliedPrice=value;   }
protected:
   //--- 创建指标
   bool              CreateCOG(CIndicators *indicators);



  };
//+------------------------------------------------------------------+
//| 构造函数|
//+------------------------------------------------------------------+
COG::COG(void) :           m_Period_(10),                // 指标平均周期
                           m_SmoothPeriod(3),            // 信号线平滑周期 
                           m_MA_Method_(MODE_EMA),       // 信号线平均法
                           m_AppliedPrice(1)             // 价格常数
  {
  }
//+------------------------------------------------------------------+
//||
//+------------------------------------------------------------------+
COG::~COG()
  {
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//} 检查输入参数,如果一切正常则返回 true。
//+------------------------------------------------------------------+
bool COG:: ValidationSettings()
  {
   //--- 调用基类方法
   if(!CExpertSignal::ValidationSettings())  return(false);
   //--- 检查周期,用于计算 MA 的条数 >=1
   if(m_Period_<1)
     {
      PrintFormat("Incorrect value set for one of the period! Period_=%d",
                  m_Period_);
      return false;
     }
//--- 检查周期,用于计算 MA 的条数 >=1
   if(m_SmoothPeriod<1)
     {
      PrintFormat("Incorrect value set for one of the period! m_SmoothPeriod=%d",
                  m_SmoothPeriod);
      return false;
     }
//--- 快速 MA 平滑类型必须是枚举的四个值之一
   if(m_MA_Method_!=MODE_SMA && m_MA_Method_!=MODE_EMA && m_MA_Method_!=MODE_SMMA && m_MA_Method_!=MODE_LWMA)
     {
      PrintFormat("Invalid type of smoothing of the fast MA!");
      return false;
     }
//--- m_AppliedPrice 必须有效。
   if(m_AppliedPrice<1 || m_AppliedPrice>11) 
     {
      PrintFormat("Invalid type of Price!");
      return false;
     }
//--- 所有检查均已完成,一切正常
   return true;
  }
//+------------------------------------------------------------------+
//| 创建指标|
//| 输入:指向指示符集合的指针
//| 输出:成功则为 true,否则为 false
//+------------------------------------------------------------------+
bool COG::InitIndicators(CIndicators *indicators)
  {
//--- 对 NULL 指标集合进行标准检查
   if(indicators==NULL) return(false);
//-- 在附加过滤器中初始化指标和时间序列
   if(!CExpertSignal::InitIndicators(indicators)) return(false);
//--- 创建我们的指标
   if(!CreateCOG(indicators))                  return(false);   
//-- 达到这一部分,因此函数成功执行,返回 true
   return(true);
  }
//+------------------------------------------------------------------+
//| 创建 "COG "指示器|
//+------------------------------------------------------------------+
bool COG::CreateCOG(CIndicators *indicators)
  {
//--- 检查指针
   if(indicators==NULL) return(false);
//--- 向集合中添加一个对象
   if(!indicators.Add(GetPointer(m_COG)))
     {
      printf(__FUNCTION__+": Error adding an object of the COG");
      return(false);
     }
//--- 设置 COG 参数
   MqlParam parameters[5];
//---
   parameters[0].type=TYPE_STRING;
   parameters[0].string_value="CenterOfGravity.ex5";
   parameters[1].type=TYPE_INT;
   parameters[1].integer_value=m_Period_;                 // 期间
   parameters[2].type=TYPE_INT;
   parameters[2].integer_value=m_SmoothPeriod;            // 信号线平滑周期
   parameters[3].type=TYPE_INT;
   parameters[3].integer_value=m_MA_Method_;              // 信号线平均法
   parameters[4].type=TYPE_INT;
   parameters[4].integer_value=m_AppliedPrice;            // 价格常数
//--- 对象初始化 
   if(!m_COG.Create(m_symbol.Name(),0,IND_CUSTOM,5,parameters))
     {
      printf(__FUNCTION__+": Error initializing the object of the COG");
      return(false);
     }
//--- 缓冲区的数量
   if(!m_COG.NumBuffers(2)) return(false);
//-- 达到这一部分,因此函数成功执行,返回 true
   return(true);
  }
//+------------------------------------------------------------------+
//| 返回买入信号的强度|
//+------------------------------------------------------------------+
int COG::LongCondition()
  {
   int signal=0;
//--- 对于使用刻度线的操作,idx=0;对于使用成形条形图的操作,idx=1
   int idx=StartIndex();
//--- 最后形成的条形图上的 COG 值
   double last_fast_value=CG(idx);
   double last_slow_value=Signal(idx);
//---最后一个(仅一个)形成条形的 COG 值
   double prev_fast_value=CG(idx+1);
   double prev_slow_value=Signal(idx+1);   
//-- 如果 CG > 信号 && CG-1 < 信号-1
   if((last_fast_value>last_slow_value) && (prev_fast_value<prev_slow_value))
     {
      signal=100; // 有买入信号
     }
//--- 返回信号值
   return(signal);
  }
//+------------------------------------------------------------------+
//| 返回卖出信号的强度|
//+------------------------------------------------------------------+
int COG::ShortCondition()
  {
   int signal=0;
//--- 对于使用刻度线的操作,idx=0;对于使用成形条形图的操作,idx=1
   int idx=StartIndex();
//--- 最后形成的条形图上的 COG 值
   double last_fast_value=CG(idx);
   double last_slow_value=Signal(idx);
//---最后一个(仅一个)形成条形的 COG 值
   double prev_fast_value=CG(idx+1);
   double prev_slow_value=Signal(idx+1);   
//--如果 CG < 信号 && CG-1 > 信号-1
   if((last_fast_value<last_slow_value) && (prev_fast_value>prev_slow_value))
     {
      signal=100; // 有卖出信号
     }
//--- 返回信号值
   return(signal);
  }
 
有趣的是......需要确定战斗条件下的算法
 

指标编译无误:

并且可以运行

------------------

只需使用固定的 smoothalgorithms.mqh文件 - 查看帖子


Indicators: T3Taotra_HTF
Indicators: T3Taotra_HTF
  • 2016.06.30
  • www.mql5.com
T3Taotra_HTF: Author: Nikolay Kositsin...