|
|
//+------------------------------------------------------------------+
//| 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 |
//+------------------------------------------------------------------+
*/复制代码 |
|