找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
首页论坛EAHub 外汇论坛
查看: 26|回复: 0

macd拐点信号检测

[复制链接]

4万

主题

54

回帖

4万

积分

管理员

积分
45954
发表于 2026-8-27 22:27:00 | 显示全部楼层 |阅读模式
//+------------------------------------------------------------------+

//|                                                     macd_chk.mqh |

//|                                  Copyright 2024, MetaQuotes Ltd. |

//|                                             https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "@大树My05613828"


class macd_chk

  {

private:

   int               macd_h;//句柄

   double            macd_z[];//数组值


public:


   bool              macd_check();

                     macd_chk();

                    ~macd_chk();

  };

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

macd_chk::macd_chk()

  {

   macd_h = iMACD(Symbol(),PERIOD_CURRENT,12,26,9,PRICE_CLOSE);

   ArraySetAsSeries(macd_z,true);//倒序

  }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

macd_chk::~macd_chk()

  {

   if(macd_h!= INVALID_HANDLE)

      macd_h =  INVALID_HANDLE;

  }

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

bool      macd_chk:: macd_check()

  {

  CopyBuffer(macd_h,0,0,20,macd_z);


   if(macd_z[0]<macd_z[1])//判断拐点

      return false;


   for(int i=1;i<10;i++)//判断减量

     {

      if(MathAbs(macd_z)>MathAbs(macd_z[i+1]))

         return false;

     }

   return true;

  }

//+------------------------------------------------------------------+

/*


#property copyright "Copyright 2024, MetaQuotes Ltd."

#property link      "https://www.mql5.com"

#property version   "1.00"

#include "macd_chk"

macd_chk cy;

//+------------------------------------------------------------------+

//| Expert initialization function                                   |

//+------------------------------------------------------------------+

int OnInit()

  {

//---


//---

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

//---


  }

//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

void OnTick()

  {

//---

  bool chk = cy.macd_check();

  }

//+------------------------------------------------------------------+

//| ChartEvent function                                              |

//+------------------------------------------------------------------+


*/


//+------------------------------------------------------------------+
//|                                                     macd_chk.mqh |
//|                                  Copyright 2024, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "@大树My05613828"

class macd_chk
  {
private:
   int               macd_h;
   double            macd_z[];

public:

   bool              macd_check();
                     macd_chk();
                    ~macd_chk();
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
macd_chk::macd_chk()
  {
   macd_h = iMACD(Symbol(),PERIOD_CURRENT,12,26,9,PRICE_CLOSE);
   ArraySetAsSeries(macd_z,true);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
macd_chk::~macd_chk()
  {
   if(macd_h!= INVALID_HANDLE)
      macd_h =  INVALID_HANDLE;
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
bool      macd_chk:: macd_check()
  {
  CopyBuffer(macd_h,0,0,20,macd_z);
  
   if(macd_z[0]<macd_z[1])
      return false;

   for(int i=1;i<10;i++)
     {
      if(MathAbs(macd_z)>MathAbs(macd_z[i+1]))
         return false;
     }
   return true;
  }
//+------------------------------------------------------------------+
/*

#property copyright "Copyright 2024, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#include "macd_chk"
macd_chk cy;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  bool chk = cy.macd_check();
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+

*/复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|EAHub外汇论坛

GMT+8, 2026-10-9 17:33 , Processed in 0.105874 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表