Consolidate Python ignore rules into root gitignore
This commit is contained in:
@@ -0,0 +1,761 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| BillWilliams.mqh |
|
||||
//| Copyright 2000-2026, MetaQuotes Ltd. |
|
||||
//| www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#include "Indicator.mqh"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CiAC. |
|
||||
//| Purpose: Class of the "Accelerator Oscillator" indicator. |
|
||||
//| Derives from class CIndicator. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CiAC : public CIndicator
|
||||
{
|
||||
public:
|
||||
CiAC(void);
|
||||
~CiAC(void);
|
||||
//--- method of creating
|
||||
bool Create(const string symbol,const ENUM_TIMEFRAMES period);
|
||||
//--- methods of access to data of indicator
|
||||
double Main(const int index) const;
|
||||
//--- method of identifying
|
||||
virtual int Type(void) const { return(IND_AC); }
|
||||
|
||||
protected:
|
||||
//--- methods of tuning
|
||||
virtual bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[]);
|
||||
bool Initialize(const string symbol,const ENUM_TIMEFRAMES period);
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiAC::CiAC(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiAC::~CiAC(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Create the "Accelerator Oscillator" indicator |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiAC::Create(const string symbol,const ENUM_TIMEFRAMES period)
|
||||
{
|
||||
//--- check history
|
||||
if(!SetSymbolPeriod(symbol,period))
|
||||
return(false);
|
||||
//--- create
|
||||
m_handle=iAC(symbol,period);
|
||||
//--- check result
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
return(false);
|
||||
//--- idicator successfully created
|
||||
if(!Initialize(symbol,period))
|
||||
{
|
||||
//--- initialization failed
|
||||
IndicatorRelease(m_handle);
|
||||
m_handle=INVALID_HANDLE;
|
||||
return(false);
|
||||
}
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with universal parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiAC::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[])
|
||||
{
|
||||
return(Initialize(symbol,period));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with special parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiAC::Initialize(const string symbol,const ENUM_TIMEFRAMES period)
|
||||
{
|
||||
if(CreateBuffers(symbol,period,1))
|
||||
{
|
||||
//--- string of status of drawing
|
||||
m_name ="AC";
|
||||
m_status="("+symbol+","+PeriodDescription()+") H="+IntegerToString(m_handle);
|
||||
//--- create buffers
|
||||
((CIndicatorBuffer*)At(0)).Name("MAIN_LINE");
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//--- error
|
||||
return(false);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Access to the buffer of "Accelerator Oscillator" |
|
||||
//+------------------------------------------------------------------+
|
||||
double CiAC::Main(const int index) const
|
||||
{
|
||||
CIndicatorBuffer *buffer=At(0);
|
||||
//--- check
|
||||
if(buffer==NULL)
|
||||
return(EMPTY_VALUE);
|
||||
//---
|
||||
return(buffer.At(index));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CiAlligator. |
|
||||
//| Purpose: Class of the "Alligator" indicator. |
|
||||
//| Derives from class CIndicator. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CiAlligator : public CIndicator
|
||||
{
|
||||
protected:
|
||||
int m_jaw_period;
|
||||
int m_jaw_shift;
|
||||
int m_teeth_period;
|
||||
int m_teeth_shift;
|
||||
int m_lips_period;
|
||||
int m_lips_shift;
|
||||
ENUM_MA_METHOD m_ma_method;
|
||||
int m_applied;
|
||||
|
||||
public:
|
||||
CiAlligator(void);
|
||||
~CiAlligator(void);
|
||||
//--- methods of access to protected data
|
||||
int JawPeriod(void) const { return(m_jaw_period); }
|
||||
int JawShift(void) const { return(m_jaw_shift); }
|
||||
int TeethPeriod(void) const { return(m_teeth_period); }
|
||||
int TeethShift(void) const { return(m_teeth_shift); }
|
||||
int LipsPeriod(void) const { return(m_lips_period); }
|
||||
int LipsShift(void) const { return(m_lips_shift); }
|
||||
ENUM_MA_METHOD MaMethod(void) const { return(m_ma_method); }
|
||||
int Applied(void) const { return(m_applied); }
|
||||
//--- method of creating
|
||||
bool Create(const string symbol,const ENUM_TIMEFRAMES period,
|
||||
const int jaw_period,const int jaw_shift,
|
||||
const int teeth_period,const int teeth_shift,
|
||||
const int lips_period,const int lips_shift,
|
||||
const ENUM_MA_METHOD ma_method,const int applied);
|
||||
//--- methods of access to data of indicator
|
||||
double Jaw(const int index) const;
|
||||
double Teeth(const int index) const;
|
||||
double Lips(const int index) const;
|
||||
//--- method of identifying
|
||||
virtual int Type(void) const { return(IND_ALLIGATOR); }
|
||||
|
||||
protected:
|
||||
//--- methods of tuning
|
||||
virtual bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[]);
|
||||
bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,
|
||||
const int jaw_period,const int jaw_shift,
|
||||
const int teeth_period,const int teeth_shift,
|
||||
const int lips_period,const int lips_shift,
|
||||
const ENUM_MA_METHOD ma_method,const int applied);
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiAlligator::CiAlligator(void) : m_jaw_period(-1),
|
||||
m_jaw_shift(-1),
|
||||
m_teeth_period(-1),
|
||||
m_teeth_shift(-1),
|
||||
m_lips_period(-1),
|
||||
m_lips_shift(-1),
|
||||
m_ma_method(WRONG_VALUE),
|
||||
m_applied(-1)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiAlligator::~CiAlligator(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Create the "Alligator" indicator |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiAlligator::Create(const string symbol,const ENUM_TIMEFRAMES period,
|
||||
const int jaw_period,const int jaw_shift,
|
||||
const int teeth_period,const int teeth_shift,
|
||||
const int lips_period,const int lips_shift,
|
||||
const ENUM_MA_METHOD ma_method,const int applied)
|
||||
{
|
||||
//--- check history
|
||||
if(!SetSymbolPeriod(symbol,period))
|
||||
return(false);
|
||||
//--- create
|
||||
m_handle=iAlligator(symbol,period,jaw_period,jaw_shift,teeth_period,teeth_shift,lips_period,lips_shift,ma_method,applied);
|
||||
//--- check result
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
return(false);
|
||||
//--- idicator successfully created
|
||||
if(!Initialize(symbol,period,jaw_period,jaw_shift,teeth_period,teeth_shift,lips_period,lips_shift,ma_method,applied))
|
||||
{
|
||||
//--- initialization failed
|
||||
IndicatorRelease(m_handle);
|
||||
m_handle=INVALID_HANDLE;
|
||||
return(false);
|
||||
}
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with universal parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiAlligator::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[])
|
||||
{
|
||||
return(Initialize(symbol,period,(int)params[0].integer_value,(int)params[1].integer_value,
|
||||
(int)params[2].integer_value,(int)params[3].integer_value,
|
||||
(int)params[4].integer_value,(int)params[5].integer_value,
|
||||
(ENUM_MA_METHOD)params[6].integer_value,(int)params[7].integer_value));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with special parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiAlligator::Initialize(const string symbol,const ENUM_TIMEFRAMES period,
|
||||
const int jaw_period,const int jaw_shift,
|
||||
const int teeth_period,const int teeth_shift,
|
||||
const int lips_period,const int lips_shift,
|
||||
const ENUM_MA_METHOD ma_method,const int applied)
|
||||
{
|
||||
if(CreateBuffers(symbol,period,3))
|
||||
{
|
||||
//--- string of status of drawing
|
||||
m_name ="Alligator";
|
||||
m_status="("+symbol+","+PeriodDescription()+","+
|
||||
IntegerToString(jaw_period)+","+IntegerToString(jaw_shift)+","+
|
||||
IntegerToString(teeth_period)+","+IntegerToString(teeth_shift)+","+
|
||||
IntegerToString(lips_period)+","+IntegerToString(lips_shift)+","+
|
||||
MethodDescription(ma_method)+","+PriceDescription(applied)+") H="+IntegerToString(m_handle);
|
||||
//--- save settings
|
||||
m_jaw_period =jaw_period;
|
||||
m_jaw_shift =jaw_shift;
|
||||
m_teeth_period=teeth_period;
|
||||
m_teeth_shift =teeth_shift;
|
||||
m_lips_period =lips_period;
|
||||
m_lips_shift =lips_shift;
|
||||
m_ma_method =ma_method;
|
||||
m_applied =applied;
|
||||
//--- create buffers
|
||||
((CIndicatorBuffer*)At(0)).Name("JAW_LINE");
|
||||
((CIndicatorBuffer*)At(0)).Offset(jaw_shift);
|
||||
((CIndicatorBuffer*)At(1)).Name("TEETH_LINE");
|
||||
((CIndicatorBuffer*)At(1)).Offset(teeth_shift);
|
||||
((CIndicatorBuffer*)At(2)).Name("LIPS_LINE");
|
||||
((CIndicatorBuffer*)At(2)).Offset(lips_shift);
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//--- error
|
||||
return(false);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Access to Jaw buffer of "Alligator" |
|
||||
//+------------------------------------------------------------------+
|
||||
double CiAlligator::Jaw(const int index) const
|
||||
{
|
||||
CIndicatorBuffer *buffer=At(0);
|
||||
//--- check
|
||||
if(buffer==NULL)
|
||||
return(EMPTY_VALUE);
|
||||
//---
|
||||
return(buffer.At(index));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Access to Teeth buffer of "Alligator" |
|
||||
//+------------------------------------------------------------------+
|
||||
double CiAlligator::Teeth(const int index) const
|
||||
{
|
||||
CIndicatorBuffer *buffer=At(1);
|
||||
//--- check
|
||||
if(buffer==NULL)
|
||||
return(EMPTY_VALUE);
|
||||
//---
|
||||
return(buffer.At(index));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Access to Lips buffer of "Alligator" |
|
||||
//+------------------------------------------------------------------+
|
||||
double CiAlligator::Lips(const int index) const
|
||||
{
|
||||
CIndicatorBuffer *buffer=At(2);
|
||||
//--- check
|
||||
if(buffer==NULL)
|
||||
return(EMPTY_VALUE);
|
||||
//---
|
||||
return(buffer.At(index));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CiAO. |
|
||||
//| Purpose: Class of the "Awesome Oscillator" indicator. |
|
||||
//| Derives from class CIndicator. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CiAO : public CIndicator
|
||||
{
|
||||
public:
|
||||
CiAO(void);
|
||||
~CiAO(void);
|
||||
//--- method of creating
|
||||
bool Create(const string symbol,const ENUM_TIMEFRAMES period);
|
||||
//--- methods of access to data of indicator
|
||||
double Main(const int index) const;
|
||||
//--- method of identifying
|
||||
virtual int Type(void) const { return(IND_AO); }
|
||||
|
||||
protected:
|
||||
//--- methods of tuning
|
||||
virtual bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[]);
|
||||
bool Initialize(const string symbol,const ENUM_TIMEFRAMES period);
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiAO::CiAO(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiAO::~CiAO(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Create the "Awesome Oscillator" indicator |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiAO::Create(const string symbol,const ENUM_TIMEFRAMES period)
|
||||
{
|
||||
//--- check history
|
||||
if(!SetSymbolPeriod(symbol,period))
|
||||
return(false);
|
||||
//--- create
|
||||
m_handle=iAO(symbol,period);
|
||||
//--- check result
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
return(false);
|
||||
//--- indicator successfullly created
|
||||
if(!Initialize(symbol,period))
|
||||
{
|
||||
//--- initialization failed
|
||||
IndicatorRelease(m_handle);
|
||||
m_handle=INVALID_HANDLE;
|
||||
return(false);
|
||||
}
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with universal parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiAO::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[])
|
||||
{
|
||||
return(Initialize(symbol,period));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Create the "Awesome Oscillator" indicator |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiAO::Initialize(const string symbol,const ENUM_TIMEFRAMES period)
|
||||
{
|
||||
if(CreateBuffers(symbol,period,1))
|
||||
{
|
||||
//--- string of status of drawing
|
||||
m_status="AO("+symbol+","+PeriodDescription()+") H="+IntegerToString(m_handle);
|
||||
//--- create buffers
|
||||
((CIndicatorBuffer*)At(0)).Name("MAIN_LINE");
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//--- error
|
||||
return(false);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Access to buffer of "Awesome Oscillator" |
|
||||
//+------------------------------------------------------------------+
|
||||
double CiAO::Main(const int index) const
|
||||
{
|
||||
CIndicatorBuffer *buffer=At(0);
|
||||
//--- check
|
||||
if(buffer==NULL)
|
||||
return(EMPTY_VALUE);
|
||||
//---
|
||||
return(buffer.At(index));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CiFractals. |
|
||||
//| Purpose: Class of the "Fractals" indicator. |
|
||||
//| Derives from class CIndicator. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CiFractals : public CIndicator
|
||||
{
|
||||
public:
|
||||
CiFractals(void);
|
||||
~CiFractals(void);
|
||||
//--- method of creating
|
||||
bool Create(const string symbol,const ENUM_TIMEFRAMES period);
|
||||
//--- methods of access to indicator data
|
||||
double Upper(const int index) const;
|
||||
double Lower(const int index) const;
|
||||
//--- method of identifying
|
||||
virtual int Type(void) const { return(IND_FRACTALS); }
|
||||
|
||||
protected:
|
||||
//--- methods of tuning
|
||||
virtual bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[]);
|
||||
bool Initialize(const string symbol,const ENUM_TIMEFRAMES period);
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiFractals::CiFractals(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiFractals::~CiFractals(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Create the "Fractals" indicator |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiFractals::Create(const string symbol,const ENUM_TIMEFRAMES period)
|
||||
{
|
||||
//--- check history
|
||||
if(!SetSymbolPeriod(symbol,period))
|
||||
return(false);
|
||||
//--- create
|
||||
m_handle=iFractals(symbol,period);
|
||||
//--- check result
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
return(false);
|
||||
//--- idicator successfully created
|
||||
if(!Initialize(symbol,period))
|
||||
{
|
||||
//--- initialization failed
|
||||
IndicatorRelease(m_handle);
|
||||
m_handle=INVALID_HANDLE;
|
||||
return(false);
|
||||
}
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with universal parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiFractals::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[])
|
||||
{
|
||||
return(Initialize(symbol,period));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with special parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiFractals::Initialize(const string symbol,const ENUM_TIMEFRAMES period)
|
||||
{
|
||||
if(CreateBuffers(symbol,period,2))
|
||||
{
|
||||
//--- string of status of drawing
|
||||
m_name ="Fractals";
|
||||
m_status="("+symbol+","+PeriodDescription()+") H="+IntegerToString(m_handle);
|
||||
//--- create buffers
|
||||
((CIndicatorBuffer*)At(0)).Name("UPPER_LINE");
|
||||
((CIndicatorBuffer*)At(1)).Name("LOWER_LINE");
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//--- error
|
||||
return(false);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Access to Upper buffer of "Fractals" |
|
||||
//+------------------------------------------------------------------+
|
||||
double CiFractals::Upper(const int index) const
|
||||
{
|
||||
CIndicatorBuffer *buffer=At(0);
|
||||
//--- check
|
||||
if(buffer==NULL)
|
||||
return(EMPTY_VALUE);
|
||||
//---
|
||||
return(buffer.At(index));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Access to Lower buffer of "Fractals" |
|
||||
//+------------------------------------------------------------------+
|
||||
double CiFractals::Lower(const int index) const
|
||||
{
|
||||
CIndicatorBuffer *buffer=At(1);
|
||||
//--- check
|
||||
if(buffer==NULL)
|
||||
return(EMPTY_VALUE);
|
||||
//---
|
||||
return(buffer.At(index));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CiGator. |
|
||||
//| Purpose: Class of the "Gator oscillator" indicator. |
|
||||
//| Derives from class CIndicator. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CiGator : public CIndicator
|
||||
{
|
||||
protected:
|
||||
int m_jaw_period;
|
||||
int m_jaw_shift;
|
||||
int m_teeth_period;
|
||||
int m_teeth_shift;
|
||||
int m_lips_period;
|
||||
int m_lips_shift;
|
||||
ENUM_MA_METHOD m_ma_method;
|
||||
int m_applied;
|
||||
|
||||
public:
|
||||
CiGator(void);
|
||||
~CiGator(void);
|
||||
//--- methods of access to protected data
|
||||
int JawPeriod(void) const { return(m_jaw_period); }
|
||||
int JawShift(void) const { return(m_jaw_shift); }
|
||||
int TeethPeriod(void) const { return(m_teeth_period); }
|
||||
int TeethShift(void) const { return(m_teeth_shift); }
|
||||
int LipsPeriod(void) const { return(m_lips_period); }
|
||||
int LipsShift(void) const { return(m_lips_shift); }
|
||||
ENUM_MA_METHOD MaMethod(void) const { return(m_ma_method); }
|
||||
int Applied(void) const { return(m_applied); }
|
||||
//--- method of creating
|
||||
bool Create(const string symbol,const ENUM_TIMEFRAMES period,
|
||||
const int jaw_period,const int jaw_shift,
|
||||
const int teeth_period,const int teeth_shift,
|
||||
const int lips_period,const int lips_shift,
|
||||
const ENUM_MA_METHOD ma_method,const int applied);
|
||||
//--- methods of access to data of indicator
|
||||
double Upper(const int index) const;
|
||||
double Lower(const int index) const;
|
||||
//--- method of identifying
|
||||
virtual int Type(void) const { return(IND_GATOR); }
|
||||
|
||||
protected:
|
||||
//--- methods of tuning
|
||||
virtual bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[]);
|
||||
bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,
|
||||
const int jaw_period,const int jaw_shift,
|
||||
const int teeth_period,const int teeth_shift,
|
||||
const int lips_period,const int lips_shift,
|
||||
const ENUM_MA_METHOD ma_method,const int applied);
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiGator::CiGator(void) : m_jaw_period(-1),
|
||||
m_jaw_shift(-1),
|
||||
m_teeth_period(-1),
|
||||
m_teeth_shift(-1),
|
||||
m_lips_period(-1),
|
||||
m_lips_shift(-1),
|
||||
m_ma_method(WRONG_VALUE),
|
||||
m_applied(-1)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiGator::~CiGator(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Create indicator "Gator oscillator" |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiGator::Create(const string symbol,const ENUM_TIMEFRAMES period,
|
||||
const int jaw_period,const int jaw_shift,
|
||||
const int teeth_period,const int teeth_shift,
|
||||
const int lips_period,const int lips_shift,
|
||||
const ENUM_MA_METHOD ma_method,const int applied)
|
||||
{
|
||||
//--- check history
|
||||
if(!SetSymbolPeriod(symbol,period))
|
||||
return(false);
|
||||
//--- create
|
||||
m_handle=iGator(symbol,period,jaw_period,jaw_shift,teeth_period,teeth_shift,lips_period,lips_shift,ma_method,applied);
|
||||
//--- check result
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
return(false);
|
||||
//--- idicator successfully created
|
||||
if(!Initialize(symbol,period,jaw_period,jaw_shift,teeth_period,teeth_shift,lips_period,lips_shift,ma_method,applied))
|
||||
{
|
||||
//--- initialization failed
|
||||
IndicatorRelease(m_handle);
|
||||
m_handle=INVALID_HANDLE;
|
||||
return(false);
|
||||
}
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with universal parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiGator::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[])
|
||||
{
|
||||
return(Initialize(symbol,period,(int)params[0].integer_value,(int)params[1].integer_value,
|
||||
(int)params[2].integer_value,(int)params[3].integer_value,
|
||||
(int)params[4].integer_value,(int)params[5].integer_value,
|
||||
(ENUM_MA_METHOD)params[6].integer_value,(int)params[7].integer_value));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with special parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiGator::Initialize(const string symbol,const ENUM_TIMEFRAMES period,
|
||||
const int jaw_period,const int jaw_shift,
|
||||
const int teeth_period,const int teeth_shift,
|
||||
const int lips_period,const int lips_shift,
|
||||
const ENUM_MA_METHOD ma_method,const int applied)
|
||||
{
|
||||
if(CreateBuffers(symbol,period,2))
|
||||
{
|
||||
//--- string of status drawing
|
||||
m_name ="Gator";
|
||||
m_status="("+symbol+","+PeriodDescription()+","+
|
||||
IntegerToString(jaw_period)+","+IntegerToString(jaw_shift)+","+
|
||||
IntegerToString(teeth_period)+","+IntegerToString(teeth_shift)+","+
|
||||
IntegerToString(lips_period)+","+IntegerToString(lips_shift)+","+
|
||||
MethodDescription(ma_method)+","+PriceDescription(applied)+") H="+IntegerToString(m_handle);
|
||||
//--- save settings
|
||||
m_jaw_period =jaw_period;
|
||||
m_jaw_shift =jaw_shift;
|
||||
m_teeth_period=teeth_period;
|
||||
m_teeth_shift =teeth_shift;
|
||||
m_lips_period =lips_period;
|
||||
m_lips_shift =lips_shift;
|
||||
m_ma_method =ma_method;
|
||||
m_applied =applied;
|
||||
//--- create buffers
|
||||
((CIndicatorBuffer*)At(0)).Name("UPPER_LINE");
|
||||
((CIndicatorBuffer*)At(0)).Offset(teeth_shift);
|
||||
((CIndicatorBuffer*)At(1)).Name("LOWER_LINE");
|
||||
((CIndicatorBuffer*)At(1)).Offset(lips_shift);
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//--- error
|
||||
return(false);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Access to Upper buffer of "Gator oscillator" |
|
||||
//+------------------------------------------------------------------+
|
||||
double CiGator::Upper(const int index) const
|
||||
{
|
||||
CIndicatorBuffer *buffer=At(0);
|
||||
//--- check
|
||||
if(buffer==NULL)
|
||||
return(EMPTY_VALUE);
|
||||
//---
|
||||
return(buffer.At(index));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Access to Lower buffer of "Gator oscillator" |
|
||||
//+------------------------------------------------------------------+
|
||||
double CiGator::Lower(const int index) const
|
||||
{
|
||||
CIndicatorBuffer *buffer=At(1);
|
||||
//--- check
|
||||
if(buffer==NULL)
|
||||
return(EMPTY_VALUE);
|
||||
//---
|
||||
return(buffer.At(index));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CiBWMFI. |
|
||||
//| Purpose: Class of the "Market Facilitation Index" indicator |
|
||||
//| by Bill Williams". |
|
||||
//| Derives from class CIndicator. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CiBWMFI : public CIndicator
|
||||
{
|
||||
protected:
|
||||
ENUM_APPLIED_VOLUME m_applied;
|
||||
|
||||
public:
|
||||
CiBWMFI(void);
|
||||
~CiBWMFI(void);
|
||||
//--- methods of access to protected data
|
||||
ENUM_APPLIED_VOLUME Applied(void) const { return(m_applied); }
|
||||
//--- method of creating
|
||||
bool Create(const string symbol,const ENUM_TIMEFRAMES period,const ENUM_APPLIED_VOLUME applied);
|
||||
//--- methods of access to data of indicator
|
||||
double Main(const int index) const;
|
||||
//--- method of identifying
|
||||
virtual int Type(void) const { return(IND_BWMFI); }
|
||||
|
||||
protected:
|
||||
//--- methods of tuning
|
||||
virtual bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[]);
|
||||
bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const ENUM_APPLIED_VOLUME applied);
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiBWMFI::CiBWMFI(void) : m_applied(WRONG_VALUE)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiBWMFI::~CiBWMFI(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Create "Market Facilitation Index by Bill Williams" indicator |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiBWMFI::Create(const string symbol,const ENUM_TIMEFRAMES period,const ENUM_APPLIED_VOLUME applied)
|
||||
{
|
||||
//--- check history
|
||||
if(!SetSymbolPeriod(symbol,period))
|
||||
return(false);
|
||||
//--- create
|
||||
m_handle=iBWMFI(symbol,period,applied);
|
||||
//--- check result
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
return(false);
|
||||
//--- idicator successfully created
|
||||
if(!Initialize(symbol,period,applied))
|
||||
{
|
||||
//--- initialization failed
|
||||
IndicatorRelease(m_handle);
|
||||
m_handle=INVALID_HANDLE;
|
||||
return(false);
|
||||
}
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with universal parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiBWMFI::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[])
|
||||
{
|
||||
return(Initialize(symbol,period,(ENUM_APPLIED_VOLUME)params[0].integer_value));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize indicator with the special parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiBWMFI::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const ENUM_APPLIED_VOLUME applied)
|
||||
{
|
||||
if(CreateBuffers(symbol,period,1))
|
||||
{
|
||||
//--- string of status of drawing
|
||||
m_name ="BWMFI";
|
||||
m_status="BWMFI("+symbol+","+PeriodDescription()+","+VolumeDescription(applied)+") H="+IntegerToString(m_handle);
|
||||
//--- save settings
|
||||
m_applied=applied;
|
||||
//--- create buffers
|
||||
((CIndicatorBuffer*)At(0)).Name("MAIN_LINE");
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//--- error
|
||||
return(false);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Access to buffer of "Market Facilitation Index by Bill Williams".|
|
||||
//+------------------------------------------------------------------+
|
||||
double CiBWMFI::Main(const int index) const
|
||||
{
|
||||
CIndicatorBuffer *buffer=At(0);
|
||||
//--- check
|
||||
if(buffer==NULL)
|
||||
return(EMPTY_VALUE);
|
||||
//---
|
||||
return(buffer.At(index));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,225 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Custom.mqh |
|
||||
//| Copyright 2000-2026, MetaQuotes Ltd. |
|
||||
//| www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#include "Indicator.mqh"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CiCustom. |
|
||||
//| Purpose: Class of custom indicators. |
|
||||
//| Derives from class CIndicator. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CiCustom : public CIndicator
|
||||
{
|
||||
protected:
|
||||
int m_num_params; // number of creation parameters
|
||||
MqlParam m_params[]; // creation parameters
|
||||
|
||||
public:
|
||||
CiCustom(void);
|
||||
~CiCustom(void);
|
||||
//--- methods of access to protected data
|
||||
bool NumBuffers(const int buffers);
|
||||
int NumParams(void) const { return(m_num_params); }
|
||||
ENUM_DATATYPE ParamType(const int ind) const;
|
||||
long ParamLong(const int ind) const;
|
||||
double ParamDouble(const int ind) const;
|
||||
string ParamString(const int ind) const;
|
||||
//--- method of identifying
|
||||
virtual int Type(void) const { return(IND_CUSTOM); }
|
||||
|
||||
protected:
|
||||
//--- methods of tuning
|
||||
virtual bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[]);
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiCustom::CiCustom(void) : m_num_params(0)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiCustom::~CiCustom(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Set number of buffers of indicator |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiCustom::NumBuffers(const int buffers)
|
||||
{
|
||||
bool result=true;
|
||||
//---
|
||||
if(m_buffers_total==0)
|
||||
{
|
||||
m_buffers_total=buffers;
|
||||
return(true);
|
||||
}
|
||||
if(m_buffers_total!=buffers)
|
||||
{
|
||||
Shutdown();
|
||||
result=CreateBuffers(m_symbol,m_period,buffers);
|
||||
if(result)
|
||||
{
|
||||
//--- create buffers
|
||||
for(int i=0;i<m_buffers_total;i++)
|
||||
((CIndicatorBuffer*)At(i)).Name("LINE "+IntegerToString(i));
|
||||
}
|
||||
}
|
||||
//---
|
||||
return(result);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Get type of specified parameter of creation |
|
||||
//+------------------------------------------------------------------+
|
||||
ENUM_DATATYPE CiCustom::ParamType(const int ind) const
|
||||
{
|
||||
if(ind>=m_num_params)
|
||||
return(WRONG_VALUE);
|
||||
//---
|
||||
return(m_params[ind].type);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Get specified parameter of creatiob as a long value |
|
||||
//+------------------------------------------------------------------+
|
||||
long CiCustom::ParamLong(const int ind) const
|
||||
{
|
||||
if(ind<m_num_params)
|
||||
{
|
||||
switch(m_params[ind].type)
|
||||
{
|
||||
case TYPE_BOOL:
|
||||
case TYPE_CHAR:
|
||||
case TYPE_UCHAR:
|
||||
case TYPE_SHORT:
|
||||
case TYPE_USHORT:
|
||||
case TYPE_INT:
|
||||
case TYPE_UINT:
|
||||
case TYPE_COLOR:
|
||||
case TYPE_LONG:
|
||||
case TYPE_ULONG:
|
||||
case TYPE_DATETIME:
|
||||
return(m_params[ind].integer_value);
|
||||
case TYPE_STRING:
|
||||
case TYPE_DOUBLE:
|
||||
case TYPE_FLOAT:
|
||||
case TYPE_VECTOR:
|
||||
case TYPE_VECTORF:
|
||||
case TYPE_VECTORC:
|
||||
case TYPE_VECTORCF:
|
||||
case TYPE_MATRIX:
|
||||
case TYPE_MATRIXF:
|
||||
case TYPE_MATRIXC:
|
||||
case TYPE_MATRIXCF:
|
||||
break;
|
||||
}
|
||||
}
|
||||
//---
|
||||
return(0);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Get specified parameter of creation as a double value |
|
||||
//+------------------------------------------------------------------+
|
||||
double CiCustom::ParamDouble(const int ind) const
|
||||
{
|
||||
if(ind>=m_num_params)
|
||||
return(EMPTY_VALUE);
|
||||
switch(m_params[ind].type)
|
||||
{
|
||||
case TYPE_DOUBLE:
|
||||
case TYPE_FLOAT:
|
||||
break;
|
||||
default:
|
||||
return(EMPTY_VALUE);
|
||||
}
|
||||
//---
|
||||
return(m_params[ind].double_value);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Get specified parameter of creation as a string value |
|
||||
//+------------------------------------------------------------------+
|
||||
string CiCustom::ParamString(const int ind) const
|
||||
{
|
||||
if(ind>=m_num_params || m_params[ind].type!=TYPE_STRING)
|
||||
return("");
|
||||
//---
|
||||
return(m_params[ind].string_value);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with universal parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiCustom::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[])
|
||||
{
|
||||
int i;
|
||||
//--- tune
|
||||
if(m_buffers_total==0)
|
||||
m_buffers_total=256;
|
||||
if(CreateBuffers(symbol,period,m_buffers_total))
|
||||
{
|
||||
//--- string of status of drawing
|
||||
m_name ="Custom "+params[0].string_value;
|
||||
m_status="("+symbol+","+PeriodDescription();
|
||||
for(i=1;i<num_params;i++)
|
||||
{
|
||||
switch(params[i].type)
|
||||
{
|
||||
case TYPE_BOOL:
|
||||
m_status=m_status+","+((params[i].integer_value)?"true":"false");
|
||||
break;
|
||||
case TYPE_CHAR:
|
||||
case TYPE_UCHAR:
|
||||
case TYPE_SHORT:
|
||||
case TYPE_USHORT:
|
||||
case TYPE_INT:
|
||||
case TYPE_UINT:
|
||||
case TYPE_LONG:
|
||||
case TYPE_ULONG:
|
||||
m_status=m_status+","+IntegerToString(params[i].integer_value);
|
||||
break;
|
||||
case TYPE_COLOR:
|
||||
m_status=m_status+","+ColorToString((color)params[i].integer_value);
|
||||
break;
|
||||
case TYPE_DATETIME:
|
||||
m_status=m_status+","+TimeToString(params[i].integer_value);
|
||||
break;
|
||||
case TYPE_FLOAT:
|
||||
case TYPE_DOUBLE:
|
||||
m_status=m_status+","+DoubleToString(params[i].double_value);
|
||||
break;
|
||||
case TYPE_STRING:
|
||||
m_status=m_status+",'"+params[i].string_value+"'";
|
||||
break;
|
||||
case TYPE_VECTOR:
|
||||
case TYPE_VECTORF:
|
||||
case TYPE_VECTORC:
|
||||
case TYPE_VECTORCF:
|
||||
case TYPE_MATRIX:
|
||||
case TYPE_MATRIXF:
|
||||
case TYPE_MATRIXC:
|
||||
case TYPE_MATRIXCF:
|
||||
m_status=m_status+",<NA>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_status=m_status+") H="+IntegerToString(m_handle);
|
||||
//--- save settings
|
||||
ArrayResize(m_params,num_params);
|
||||
for(i=0;i<num_params;i++)
|
||||
{
|
||||
m_params[i].type =params[i].type;
|
||||
m_params[i].integer_value=params[i].integer_value;
|
||||
m_params[i].double_value =params[i].double_value;
|
||||
m_params[i].string_value =params[i].string_value;
|
||||
}
|
||||
m_num_params=num_params;
|
||||
//--- create buffers
|
||||
for(i=0;i<m_buffers_total;i++)
|
||||
((CIndicatorBuffer*)At(i)).Name("LINE "+IntegerToString(i));
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//--- error
|
||||
return(false);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,516 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Indicator.mqh |
|
||||
//| Copyright 2000-2026, MetaQuotes Ltd. |
|
||||
//| www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#include "Series.mqh"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CIndicatorBuffer. |
|
||||
//| Purpose: Class for access to data of buffers of |
|
||||
//| technical indicators. |
|
||||
//| Derives from class CDoubleBuffer. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CIndicatorBuffer : public CDoubleBuffer
|
||||
{
|
||||
protected:
|
||||
int m_offset; // shift along the time axis (in bars)
|
||||
string m_name; // name of buffer
|
||||
|
||||
public:
|
||||
CIndicatorBuffer(void);
|
||||
~CIndicatorBuffer(void);
|
||||
//--- methods of access to protected data
|
||||
int Offset(void) const { return(m_offset); }
|
||||
void Offset(const int offset) { m_offset=offset; }
|
||||
string Name(void) const { return(m_name); }
|
||||
void Name(const string name) { m_name=name; }
|
||||
//--- methods of access to data
|
||||
double At(const int index) const;
|
||||
//--- method of refreshing of data in buffer
|
||||
bool Refresh(const int handle,const int num);
|
||||
bool RefreshCurrent(const int handle,const int num);
|
||||
|
||||
private:
|
||||
virtual bool Refresh(void) { return(CDoubleBuffer::Refresh()); }
|
||||
virtual bool RefreshCurrent(void) { return(CDoubleBuffer::RefreshCurrent()); }
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CIndicatorBuffer::CIndicatorBuffer(void) : m_offset(0),
|
||||
m_name("")
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CIndicatorBuffer::~CIndicatorBuffer(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Access to data in a specified position |
|
||||
//+------------------------------------------------------------------+
|
||||
double CIndicatorBuffer::At(const int index) const
|
||||
{
|
||||
return(CDoubleBuffer::At(index+m_offset));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Refreshing of data in buffer |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CIndicatorBuffer::Refresh(const int handle,const int num)
|
||||
{
|
||||
//--- check
|
||||
if(handle==INVALID_HANDLE)
|
||||
{
|
||||
SetUserError(ERR_USER_INVALID_HANDLE);
|
||||
return(false);
|
||||
}
|
||||
//---
|
||||
m_data_total=CopyBuffer(handle,num,-m_offset,m_size,m_data);
|
||||
//---
|
||||
return(m_data_total>0);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Refreshing of the data in buffer |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CIndicatorBuffer::RefreshCurrent(const int handle,const int num)
|
||||
{
|
||||
double array[1];
|
||||
//--- check
|
||||
if(handle==INVALID_HANDLE)
|
||||
{
|
||||
SetUserError(ERR_USER_INVALID_HANDLE);
|
||||
return(false);
|
||||
}
|
||||
//---
|
||||
if(CopyBuffer(handle,num,-m_offset,1,array)>0 && m_data_total>0)
|
||||
{
|
||||
m_data[0]=array[0];
|
||||
return(true);
|
||||
}
|
||||
//--- error
|
||||
return(false);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CIndicator. |
|
||||
//| Purpose: Base class of technical indicators. |
|
||||
//| Derives from class CSeries. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CIndicator : public CSeries
|
||||
{
|
||||
protected:
|
||||
int m_handle; // indicator handle
|
||||
string m_status; // status of creation
|
||||
bool m_full_release; // flag
|
||||
bool m_redrawer; // flag
|
||||
|
||||
public:
|
||||
CIndicator(void);
|
||||
~CIndicator(void);
|
||||
//--- methods of access to protected data
|
||||
int Handle(void) const { return(m_handle); }
|
||||
string Status(void) const { return(m_status); }
|
||||
void FullRelease(const bool flag=true) { m_full_release=flag; }
|
||||
void Redrawer(const bool flag=true) { m_redrawer=flag; }
|
||||
//--- method for creating
|
||||
bool Create(const string symbol,const ENUM_TIMEFRAMES period,
|
||||
const ENUM_INDICATOR type,const int num_params,const MqlParam ¶ms[]);
|
||||
virtual bool BufferResize(const int size);
|
||||
//--- methods of access to data
|
||||
int BarsCalculated(void) const;
|
||||
double GetData(const int buffer_num,const int index) const;
|
||||
int GetData(const int start_pos,const int count,const int buffer_num,double &buffer[]) const;
|
||||
int GetData(const datetime start_time,const int count,const int buffer_num,double &buffer[]) const;
|
||||
int GetData(const datetime start_time,const datetime stop_time,const int buffer_num,double &buffer[]) const;
|
||||
//--- methods for find extremum
|
||||
int Minimum(const int buffer_num,const int start,const int count) const;
|
||||
double MinValue(const int buffer_num,const int start,const int count,int &index) const;
|
||||
int Maximum(const int buffer_num,const int start,const int count) const;
|
||||
double MaxValue(const int buffer_num,const int start,const int count,int &index) const;
|
||||
//--- method of "freshening" of the data
|
||||
virtual void Refresh(const int flags=OBJ_ALL_PERIODS);
|
||||
//--- methods for working with chart
|
||||
bool AddToChart(const long chart,const int subwin);
|
||||
bool DeleteFromChart(const long chart,const int subwin);
|
||||
//--- methods of conversion of constants to strings
|
||||
static string MethodDescription(const int val);
|
||||
static string PriceDescription(const int val);
|
||||
static string VolumeDescription(const int val);
|
||||
|
||||
protected:
|
||||
//--- methods of tuning
|
||||
bool CreateBuffers(const string symbol,const ENUM_TIMEFRAMES period,const int buffers);
|
||||
virtual bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,
|
||||
const int num_params,const MqlParam ¶ms[]) {return(false);}
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
void CIndicator::CIndicator(void) : m_handle(INVALID_HANDLE),
|
||||
m_status(""),
|
||||
m_full_release(false),
|
||||
m_redrawer(false)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
void CIndicator::~CIndicator(void)
|
||||
{
|
||||
//--- indicator handle release
|
||||
if(m_full_release && m_handle!=INVALID_HANDLE)
|
||||
{
|
||||
IndicatorRelease(m_handle);
|
||||
m_handle=INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Creation of the indicator with universal parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CIndicator::Create(const string symbol,const ENUM_TIMEFRAMES period,
|
||||
const ENUM_INDICATOR type,const int num_params,const MqlParam ¶ms[])
|
||||
{
|
||||
//--- check history
|
||||
if(!SetSymbolPeriod(symbol,period))
|
||||
return(false);
|
||||
//--- create
|
||||
m_handle=IndicatorCreate(symbol,period,type,num_params,params);
|
||||
//--- check result
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
return(false);
|
||||
//--- idicator successfully created
|
||||
if(!Initialize(symbol,period,num_params,params))
|
||||
{
|
||||
//--- initialization failed
|
||||
IndicatorRelease(m_handle);
|
||||
m_handle=INVALID_HANDLE;
|
||||
return(false);
|
||||
}
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Returns the amount of calculated indicator data |
|
||||
//+------------------------------------------------------------------+
|
||||
int CIndicator::BarsCalculated(void) const
|
||||
{
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
return(-1);
|
||||
//---
|
||||
return(::BarsCalculated(m_handle));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| API access method "Copying an element of indicator buffer |
|
||||
//| by specifying number of buffer and position of element" |
|
||||
//+------------------------------------------------------------------+
|
||||
double CIndicator::GetData(const int buffer_num,const int index) const
|
||||
{
|
||||
CIndicatorBuffer *buffer=At(buffer_num);
|
||||
//--- check
|
||||
if(buffer==NULL)
|
||||
{
|
||||
Print(__FUNCTION__,": invalid buffer");
|
||||
return(EMPTY_VALUE);
|
||||
}
|
||||
//---
|
||||
return(buffer.At(index));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| API access method "Copying the buffer of indicator by specifying |
|
||||
//| a start position and number of elements" |
|
||||
//+------------------------------------------------------------------+
|
||||
int CIndicator::GetData(const int start_pos,const int count,const int buffer_num,double &buffer[]) const
|
||||
{
|
||||
//--- check
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
{
|
||||
SetUserError(ERR_USER_INVALID_HANDLE);
|
||||
return(-1);
|
||||
}
|
||||
if(buffer_num>=m_buffers_total)
|
||||
{
|
||||
SetUserError(ERR_USER_INVALID_BUFF_NUM);
|
||||
return(-1);
|
||||
}
|
||||
//---
|
||||
return(CopyBuffer(m_handle,buffer_num,start_pos,count,buffer));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| API access method "Copying the buffer of indicator by specifying |
|
||||
//| start time and number of elements" |
|
||||
//+------------------------------------------------------------------+
|
||||
int CIndicator::GetData(const datetime start_time,const int count,const int buffer_num,double &buffer[]) const
|
||||
{
|
||||
//--- check
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
{
|
||||
SetUserError(ERR_USER_INVALID_HANDLE);
|
||||
return(-1);
|
||||
}
|
||||
if(buffer_num>=m_buffers_total)
|
||||
{
|
||||
SetUserError(ERR_USER_INVALID_BUFF_NUM);
|
||||
return(-1);
|
||||
}
|
||||
//---
|
||||
return(CopyBuffer(m_handle,buffer_num,start_time,count,buffer));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| API access method "Copying the buffer of indicator by specifying |
|
||||
//| start and final time |
|
||||
//+------------------------------------------------------------------+
|
||||
int CIndicator::GetData(const datetime start_time,const datetime stop_time,const int buffer_num,double &buffer[]) const
|
||||
{
|
||||
//--- check
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
{
|
||||
SetUserError(ERR_USER_INVALID_HANDLE);
|
||||
return(-1);
|
||||
}
|
||||
if(buffer_num>=m_buffers_total)
|
||||
{
|
||||
SetUserError(ERR_USER_INVALID_BUFF_NUM);
|
||||
return(-1);
|
||||
}
|
||||
//---
|
||||
return(CopyBuffer(m_handle,buffer_num,start_time,stop_time,buffer));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Find minimum of a specified buffer |
|
||||
//+------------------------------------------------------------------+
|
||||
int CIndicator::Minimum(const int buffer_num,const int start,const int count) const
|
||||
{
|
||||
//--- check
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
{
|
||||
SetUserError(ERR_USER_INVALID_HANDLE);
|
||||
return(-1);
|
||||
}
|
||||
if(buffer_num>=m_buffers_total)
|
||||
{
|
||||
SetUserError(ERR_USER_INVALID_BUFF_NUM);
|
||||
return(-1);
|
||||
}
|
||||
//---
|
||||
CIndicatorBuffer *buffer=At(buffer_num);
|
||||
if(buffer==NULL)
|
||||
return(-1);
|
||||
//---
|
||||
return(buffer.Minimum(start,count));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Find minimum of a specified buffer |
|
||||
//+------------------------------------------------------------------+
|
||||
double CIndicator::MinValue(const int buffer_num,const int start,const int count,int &index) const
|
||||
{
|
||||
int idx=Minimum(buffer_num,start,count);
|
||||
double res=EMPTY_VALUE;
|
||||
//--- check
|
||||
if(idx!=-1)
|
||||
{
|
||||
CIndicatorBuffer *buffer=At(buffer_num);
|
||||
res=buffer.At(idx);
|
||||
index=idx;
|
||||
}
|
||||
//---
|
||||
return(res);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Find maximum of a specified buffer |
|
||||
//+------------------------------------------------------------------+
|
||||
int CIndicator::Maximum(const int buffer_num,const int start,const int count) const
|
||||
{
|
||||
//--- check
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
{
|
||||
SetUserError(ERR_USER_INVALID_HANDLE);
|
||||
return(-1);
|
||||
}
|
||||
if(buffer_num>=m_buffers_total)
|
||||
{
|
||||
SetUserError(ERR_USER_INVALID_BUFF_NUM);
|
||||
return(-1);
|
||||
}
|
||||
//---
|
||||
CIndicatorBuffer *buffer=At(buffer_num);
|
||||
if(buffer==NULL)
|
||||
return(-1);
|
||||
//---
|
||||
return(buffer.Maximum(start,count));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Find maximum of specified buffer |
|
||||
//+------------------------------------------------------------------+
|
||||
double CIndicator::MaxValue(const int buffer_num,const int start,const int count,int &index) const
|
||||
{
|
||||
int idx=Maximum(buffer_num,start,count);
|
||||
double res=EMPTY_VALUE;
|
||||
//--- check
|
||||
if(idx!=-1)
|
||||
{
|
||||
CIndicatorBuffer *buffer=At(buffer_num);
|
||||
res=buffer.At(idx);
|
||||
index=idx;
|
||||
}
|
||||
//---
|
||||
return(res);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Creating data buffers of indicator |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CIndicator::CreateBuffers(const string symbol,const ENUM_TIMEFRAMES period,const int buffers)
|
||||
{
|
||||
bool result=true;
|
||||
//--- check
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
{
|
||||
SetUserError(ERR_USER_INVALID_HANDLE);
|
||||
return(false);
|
||||
}
|
||||
if(buffers==0)
|
||||
return(false);
|
||||
if(!Reserve(buffers))
|
||||
return(false);
|
||||
//---
|
||||
for(int i=0;i<buffers;i++)
|
||||
result&=Add(new CIndicatorBuffer);
|
||||
//---
|
||||
if(result)
|
||||
m_buffers_total=buffers;
|
||||
//---
|
||||
return(result);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Set size of buffers of indicator |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CIndicator::BufferResize(const int size)
|
||||
{
|
||||
if(size>m_buffer_size && !CSeries::BufferResize(size))
|
||||
return(false);
|
||||
//-- history is avalible
|
||||
int total=Total();
|
||||
for(int i=0;i<total;i++)
|
||||
{
|
||||
CIndicatorBuffer *buff=At(i);
|
||||
//--- check pointer
|
||||
if(buff==NULL)
|
||||
return(false);
|
||||
buff.Size(size);
|
||||
}
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Refreshing data of indicator |
|
||||
//+------------------------------------------------------------------+
|
||||
void CIndicator::Refresh(const int flags)
|
||||
{
|
||||
int i;
|
||||
CIndicatorBuffer *buff;
|
||||
//--- refreshing buffers
|
||||
for(i=0;i<Total();i++)
|
||||
{
|
||||
buff=At(i);
|
||||
if(m_redrawer)
|
||||
{
|
||||
buff.Refresh(m_handle,i);
|
||||
continue;
|
||||
}
|
||||
if(!(flags&m_timeframe_flags))
|
||||
{
|
||||
if(m_refresh_current)
|
||||
buff.RefreshCurrent(m_handle,i);
|
||||
}
|
||||
else
|
||||
buff.Refresh(m_handle,i);
|
||||
}
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Adds indicator to chart |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CIndicator::AddToChart(const long chart,const int subwin)
|
||||
{
|
||||
if(ChartIndicatorAdd(chart,subwin,m_handle))
|
||||
{
|
||||
m_name=ChartIndicatorName(chart,subwin,ChartIndicatorsTotal(chart,subwin)-1);
|
||||
return(true);
|
||||
}
|
||||
//--- failed
|
||||
return(false);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Deletes indicator from chart |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CIndicator::DeleteFromChart(const long chart,const int subwin)
|
||||
{
|
||||
return(ChartIndicatorDelete(chart,subwin,m_name));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Converting value of ENUM_MA_METHOD into string |
|
||||
//+------------------------------------------------------------------+
|
||||
string CIndicator::MethodDescription(const int val)
|
||||
{
|
||||
//--- select by value
|
||||
switch(val)
|
||||
{
|
||||
case ENUM_MA_METHOD::MODE_SMA:
|
||||
return("SMA");
|
||||
case ENUM_MA_METHOD::MODE_EMA:
|
||||
return("EMA");
|
||||
case ENUM_MA_METHOD::MODE_SMMA:
|
||||
return("SMMA");
|
||||
case ENUM_MA_METHOD::MODE_LWMA:
|
||||
return("LWMA");
|
||||
}
|
||||
//--- wrong value
|
||||
return("MethodUnknown="+IntegerToString(val));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Converting value of ENUM_APPLIED_PRICE into string |
|
||||
//+------------------------------------------------------------------+
|
||||
string CIndicator::PriceDescription(const int val)
|
||||
{
|
||||
//--- select by value
|
||||
switch(val)
|
||||
{
|
||||
case ENUM_APPLIED_PRICE::PRICE_CLOSE:
|
||||
return("Close");
|
||||
case ENUM_APPLIED_PRICE::PRICE_OPEN:
|
||||
return("Open");
|
||||
case ENUM_APPLIED_PRICE::PRICE_HIGH:
|
||||
return("High");
|
||||
case ENUM_APPLIED_PRICE::PRICE_LOW:
|
||||
return("Low");
|
||||
case ENUM_APPLIED_PRICE::PRICE_MEDIAN:
|
||||
return("Median");
|
||||
case ENUM_APPLIED_PRICE::PRICE_TYPICAL:
|
||||
return("Typical");
|
||||
case ENUM_APPLIED_PRICE::PRICE_WEIGHTED:
|
||||
return("Weighted");
|
||||
default:
|
||||
//--- is an indicator handle
|
||||
if(val>=10)
|
||||
return("AppliedHandle="+IntegerToString(val));
|
||||
//---
|
||||
break;
|
||||
}
|
||||
//--- wrong value
|
||||
return("PriceUnknown="+IntegerToString(val));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Converting value of ENUM_APPLIED_VOLUME into string |
|
||||
//+------------------------------------------------------------------+
|
||||
string CIndicator::VolumeDescription(const int val)
|
||||
{
|
||||
//--- select by value
|
||||
switch(val)
|
||||
{
|
||||
case ENUM_APPLIED_VOLUME::VOLUME_TICK:
|
||||
return("Tick");
|
||||
case ENUM_APPLIED_VOLUME::VOLUME_REAL:
|
||||
return("Real");
|
||||
}
|
||||
//--- wrong value
|
||||
return("VolumeUnknown="+IntegerToString(val));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,385 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Indicators.mqh |
|
||||
//| Copyright 2000-2026, MetaQuotes Ltd. |
|
||||
//| www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#include "Trend.mqh"
|
||||
#include "Oscilators.mqh"
|
||||
#include "Volumes.mqh"
|
||||
#include "BillWilliams.mqh"
|
||||
#include "Custom.mqh"
|
||||
#include "TimeSeries.mqh"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CIndicators. |
|
||||
//| Purpose: Class for creation of collection of instances of |
|
||||
//| technical indicators. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CIndicators : public CArrayObj
|
||||
{
|
||||
protected:
|
||||
MqlDateTime m_prev_time;
|
||||
|
||||
public:
|
||||
CIndicators(void);
|
||||
~CIndicators(void);
|
||||
//--- method for creation
|
||||
CIndicator *Create(const string symbol,const ENUM_TIMEFRAMES period,
|
||||
const ENUM_INDICATOR type,const int count,const MqlParam ¶ms[]);
|
||||
bool BufferResize(const int size);
|
||||
//--- method of refreshing of the data of all indicators in the collection
|
||||
int Refresh(void);
|
||||
protected:
|
||||
//--- method of formation of flags timeframes
|
||||
int TimeframesFlags(const MqlDateTime &time);
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CIndicators::CIndicators(void)
|
||||
{
|
||||
m_prev_time.min=-1;
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CIndicators::~CIndicators(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Indicator creation |
|
||||
//+------------------------------------------------------------------+
|
||||
CIndicator *CIndicators::Create(const string symbol,const ENUM_TIMEFRAMES period,
|
||||
const ENUM_INDICATOR type,const int count,const MqlParam ¶ms[])
|
||||
{
|
||||
CIndicator *result=NULL;
|
||||
//---
|
||||
switch(type)
|
||||
{
|
||||
case IND_AC:
|
||||
//--- Identifier of "Accelerator Oscillator"
|
||||
if(count==0)
|
||||
result=new CiAC;
|
||||
break;
|
||||
case IND_AD:
|
||||
//--- Identifier of "Accumulation/Distribution"
|
||||
if(count==1)
|
||||
result=new CiAD;
|
||||
break;
|
||||
case IND_ALLIGATOR:
|
||||
//--- Identifier of "Alligator"
|
||||
if(count==8)
|
||||
result=new CiAlligator;
|
||||
break;
|
||||
case IND_ADX:
|
||||
//--- Identifier of "Average Directional Index"
|
||||
if(count==1)
|
||||
result=new CiADX;
|
||||
break;
|
||||
case IND_ADXW:
|
||||
//--- Identifier of "Average Directional Index by Welles Wilder"
|
||||
if(count==1)
|
||||
result=new CiADXWilder;
|
||||
break;
|
||||
case IND_ATR:
|
||||
//--- Identifier of "Average True Range"
|
||||
if(count==1)
|
||||
result=new CiATR;
|
||||
break;
|
||||
case IND_AO:
|
||||
//--- Identifier of "Awesome Oscillator"
|
||||
if(count==0)
|
||||
result=new CiAO;
|
||||
break;
|
||||
case IND_BEARS:
|
||||
//--- Identifier of "Bears Power"
|
||||
if(count==1)
|
||||
result=new CiBearsPower;
|
||||
break;
|
||||
case IND_BANDS:
|
||||
//--- Identifier of "Bollinger Bands"
|
||||
if(count==4)
|
||||
result=new CiBands;
|
||||
break;
|
||||
case IND_BULLS:
|
||||
//--- Identifier of "Bulls Power"
|
||||
if(count==1)
|
||||
result=new CiBullsPower;
|
||||
break;
|
||||
case IND_CCI:
|
||||
//--- Identifier of "Commodity Channel Index"
|
||||
if(count==2)
|
||||
result=new CiCCI;
|
||||
break;
|
||||
case IND_CHAIKIN:
|
||||
//--- Identifier of "Chaikin Oscillator"
|
||||
if(count==4)
|
||||
result=new CiChaikin;
|
||||
break;
|
||||
case IND_DEMARKER:
|
||||
//--- Identifier of "DeMarker"
|
||||
if(count==1)
|
||||
result=new CiDeMarker;
|
||||
break;
|
||||
case IND_ENVELOPES:
|
||||
//--- Identifier of "Envelopes"
|
||||
if(count==5)
|
||||
result=new CiEnvelopes;
|
||||
break;
|
||||
case IND_FORCE:
|
||||
//--- Identifier of "Force Index"
|
||||
if(count==3)
|
||||
result=new CiForce;
|
||||
break;
|
||||
case IND_FRACTALS:
|
||||
//--- Identifier of "Fractals"
|
||||
if(count==0)
|
||||
result=new CiFractals;
|
||||
break;
|
||||
case IND_GATOR:
|
||||
//--- Identifier of "Gator oscillator"
|
||||
if(count==8)
|
||||
result=new CiGator;
|
||||
break;
|
||||
case IND_ICHIMOKU:
|
||||
//--- Identifier of "Ichimoku Kinko Hyo"
|
||||
if(count==3)
|
||||
result=new CiIchimoku;
|
||||
break;
|
||||
case IND_MACD:
|
||||
//--- Identifier of "Moving Averages Convergence-Divergence"
|
||||
if(count==4)
|
||||
result=new CiMACD;
|
||||
break;
|
||||
case IND_BWMFI:
|
||||
//--- Identifier of "Market Facilitation Index by Bill Williams"
|
||||
if(count==1)
|
||||
result=new CiBWMFI;
|
||||
break;
|
||||
case IND_MOMENTUM:
|
||||
//--- Identifier of "Momentum"
|
||||
if(count==2)
|
||||
result=new CiMomentum;
|
||||
break;
|
||||
case IND_MFI:
|
||||
//--- Identifier of "Money Flow Index"
|
||||
if(count==2)
|
||||
result=new CiMFI;
|
||||
break;
|
||||
case IND_MA:
|
||||
//--- Identifier of "Moving Average"
|
||||
if(count==4)
|
||||
result=new CiMA;
|
||||
break;
|
||||
case IND_OSMA:
|
||||
//--- Identifier of "Moving Average of Oscillator (MACD histogram)"
|
||||
if(count==4)
|
||||
result=new CiOsMA;
|
||||
break;
|
||||
case IND_OBV:
|
||||
//--- Identifier of "On Balance Volume"
|
||||
if(count==1)
|
||||
result=new CiOBV;
|
||||
break;
|
||||
case IND_SAR:
|
||||
//--- Identifier of "Parabolic Stop And Reverse System"
|
||||
if(count==2)
|
||||
result=new CiSAR;
|
||||
break;
|
||||
case IND_RSI:
|
||||
//--- Identifier of "Relative Strength Index"
|
||||
if(count==2)
|
||||
result=new CiRSI;
|
||||
break;
|
||||
case IND_RVI:
|
||||
//--- Identifier of "Relative Vigor Index"
|
||||
if(count==1)
|
||||
result=new CiRVI;
|
||||
break;
|
||||
case IND_STDDEV:
|
||||
//--- Identifier of "Standard Deviation"
|
||||
if(count==4)
|
||||
result=new CiStdDev;
|
||||
break;
|
||||
case IND_STOCHASTIC:
|
||||
//--- Identifier of "Stochastic Oscillator"
|
||||
if(count==5)
|
||||
result=new CiStochastic;
|
||||
break;
|
||||
case IND_WPR:
|
||||
//--- Identifier of "Williams' Percent Range"
|
||||
if(count==1)
|
||||
result=new CiWPR;
|
||||
break;
|
||||
case IND_DEMA:
|
||||
//--- Identifier of "Double Exponential Moving Average"
|
||||
if(count==3)
|
||||
result=new CiDEMA;
|
||||
break;
|
||||
case IND_TEMA:
|
||||
//--- Identifier of "Triple Exponential Moving Average"
|
||||
if(count==3)
|
||||
result=new CiTEMA;
|
||||
break;
|
||||
case IND_TRIX:
|
||||
//--- Identifier of "Triple Exponential Moving Averages Oscillator"
|
||||
if(count==2)
|
||||
result=new CiTriX;
|
||||
break;
|
||||
case IND_FRAMA:
|
||||
//--- Identifier of "Fractal Adaptive Moving Average"
|
||||
if(count==3)
|
||||
result=new CiFrAMA;
|
||||
break;
|
||||
case IND_AMA:
|
||||
//--- Identifier of "Adaptive Moving Average"
|
||||
if(count==5)
|
||||
result=new CiAMA;
|
||||
break;
|
||||
case IND_VIDYA:
|
||||
//--- Identifier of "Variable Index DYnamic Average"
|
||||
if(count==4)
|
||||
result=new CiVIDyA;
|
||||
break;
|
||||
case IND_VOLUMES:
|
||||
//--- Identifier of "Volumes"
|
||||
if(count==1)
|
||||
result=new CiVolumes;
|
||||
break;
|
||||
//--- Identifier of "Custom"
|
||||
case IND_CUSTOM:
|
||||
if(count>0)
|
||||
result=new CiCustom;
|
||||
break;
|
||||
}
|
||||
if(result!=NULL)
|
||||
{
|
||||
if(result.Create(symbol,period,type,count,params))
|
||||
Add(result);
|
||||
else
|
||||
{
|
||||
delete result;
|
||||
result=NULL;
|
||||
}
|
||||
}
|
||||
//---
|
||||
return(result);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Set size of buffers of all indicators in the collection |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CIndicators::BufferResize(const int size)
|
||||
{
|
||||
int total=Total();
|
||||
for(int i=0;i<total;i++)
|
||||
{
|
||||
CSeries *series=At(i);
|
||||
//--- check pointer
|
||||
if(series==NULL)
|
||||
return(false);
|
||||
if(!series.BufferResize(size))
|
||||
return(false);
|
||||
}
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Refreshing of the data of all indicators in the collection |
|
||||
//+------------------------------------------------------------------+
|
||||
int CIndicators::Refresh(void)
|
||||
{
|
||||
MqlDateTime time;
|
||||
TimeCurrent(time);
|
||||
//---
|
||||
int flags=TimeframesFlags(time);
|
||||
int total=Total();
|
||||
//---
|
||||
for(int i=0;i<total;i++)
|
||||
{
|
||||
CSeries *indicator=At(i);
|
||||
if(indicator!=NULL)
|
||||
indicator.Refresh(flags);
|
||||
}
|
||||
//---
|
||||
m_prev_time=time;
|
||||
//---
|
||||
return(flags);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Formation of timeframe flags |
|
||||
//+------------------------------------------------------------------+
|
||||
int CIndicators::TimeframesFlags(const MqlDateTime &time)
|
||||
{
|
||||
//--- set flags for all timeframes
|
||||
int result=OBJ_ALL_PERIODS;
|
||||
//--- if first check, then setting flags all timeframes
|
||||
if(m_prev_time.min==-1)
|
||||
return(result);
|
||||
//--- check change time
|
||||
if(time.min==m_prev_time.min &&
|
||||
time.hour==m_prev_time.hour &&
|
||||
time.day==m_prev_time.day &&
|
||||
time.mon==m_prev_time.mon)
|
||||
return(OBJ_NO_PERIODS);
|
||||
//--- new month?
|
||||
if(time.mon!=m_prev_time.mon)
|
||||
return(result);
|
||||
//--- reset the "new month" flag
|
||||
result^=OBJ_PERIOD_MN1;
|
||||
//--- new day?
|
||||
if(time.day!=m_prev_time.day)
|
||||
return(result);
|
||||
//--- reset the "new day" and "new week" flags
|
||||
result^=OBJ_PERIOD_D1+OBJ_PERIOD_W1;
|
||||
//--- temporary variables to speed up working with structures
|
||||
int curr,delta;
|
||||
//--- new hour?
|
||||
curr=time.hour;
|
||||
delta=curr-m_prev_time.hour;
|
||||
if(delta!=0)
|
||||
{
|
||||
if(curr%2>=delta)
|
||||
result^=OBJ_PERIOD_H2;
|
||||
if(curr%3>=delta)
|
||||
result^=OBJ_PERIOD_H3;
|
||||
if(curr%4>=delta)
|
||||
result^=OBJ_PERIOD_H4;
|
||||
if(curr%6>=delta)
|
||||
result^=OBJ_PERIOD_H6;
|
||||
if(curr%8>=delta)
|
||||
result^=OBJ_PERIOD_H8;
|
||||
if(curr%12>=delta)
|
||||
result^=OBJ_PERIOD_H12;
|
||||
return(result);
|
||||
}
|
||||
//--- reset all flags for hour timeframes
|
||||
result^=OBJ_PERIOD_H1+OBJ_PERIOD_H2+OBJ_PERIOD_H3+OBJ_PERIOD_H4+OBJ_PERIOD_H6+OBJ_PERIOD_H8+OBJ_PERIOD_H12;
|
||||
//--- new minute?
|
||||
curr=time.min;
|
||||
delta=curr-m_prev_time.min;
|
||||
if(delta!=0)
|
||||
{
|
||||
if(curr%2>=delta)
|
||||
result^=OBJ_PERIOD_M2;
|
||||
if(curr%3>=delta)
|
||||
result^=OBJ_PERIOD_M3;
|
||||
if(curr%4>=delta)
|
||||
result^=OBJ_PERIOD_M4;
|
||||
if(curr%5>=delta)
|
||||
result^=OBJ_PERIOD_M5;
|
||||
if(curr%6>=delta)
|
||||
result^=OBJ_PERIOD_M6;
|
||||
if(curr%10>=delta)
|
||||
result^=OBJ_PERIOD_M10;
|
||||
if(curr%12>=delta)
|
||||
result^=OBJ_PERIOD_M12;
|
||||
if(curr%15>=delta)
|
||||
result^=OBJ_PERIOD_M15;
|
||||
if(curr%20>=delta)
|
||||
result^=OBJ_PERIOD_M20;
|
||||
if(curr%30>=delta)
|
||||
result^=OBJ_PERIOD_M30;
|
||||
}
|
||||
//---
|
||||
return(result);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,299 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Series.mqh |
|
||||
//| Copyright 2000-2026, MetaQuotes Ltd. |
|
||||
//| www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#include <Arrays\ArrayObj.mqh>
|
||||
#include <Arrays\ArrayDouble.mqh>
|
||||
//+------------------------------------------------------------------+
|
||||
//| defines |
|
||||
//+------------------------------------------------------------------+
|
||||
#define DEFAULT_BUFFER_SIZE 1024
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CSeries. |
|
||||
//| Purpose: Base class for access to timeseries. |
|
||||
//| Derives from class CArrayObj. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CSeries : public CArrayObj
|
||||
{
|
||||
protected:
|
||||
string m_name; // name of series
|
||||
int m_buffers_total; // number of buffers
|
||||
int m_buffer_size; // buffer size
|
||||
int m_timeframe_flags; // flags of timeframes (similar to "flags of visibility of objects")
|
||||
string m_symbol; // symbol
|
||||
ENUM_TIMEFRAMES m_period; // period
|
||||
bool m_refresh_current; // flag
|
||||
//---
|
||||
datetime m_first_date;
|
||||
|
||||
public:
|
||||
CSeries(void);
|
||||
~CSeries(void);
|
||||
//--- methods of access to protected data
|
||||
string Name(void) const { return(m_name); }
|
||||
int BuffersTotal(void) const { return(m_buffers_total); }
|
||||
int BufferSize(void) const { return(m_buffer_size); }
|
||||
int Timeframe(void) const { return(m_timeframe_flags); }
|
||||
string Symbol(void) const { return(m_symbol); }
|
||||
ENUM_TIMEFRAMES Period(void) const { return(m_period); }
|
||||
string PeriodDescription(const int val=0);
|
||||
void RefreshCurrent(const bool flag) { m_refresh_current=flag; }
|
||||
//--- method of tuning
|
||||
virtual bool BufferResize(const int size);
|
||||
//--- method of refreshing" of the data
|
||||
virtual void Refresh(const int flags) { }
|
||||
|
||||
protected:
|
||||
//--- methods of tuning
|
||||
bool SetSymbolPeriod(const string symbol,const ENUM_TIMEFRAMES period);
|
||||
void PeriodToTimeframeFlag(const ENUM_TIMEFRAMES period);
|
||||
//---
|
||||
bool CheckLoadHistory(const int size);
|
||||
bool CheckTerminalHistory(const int size);
|
||||
bool CheckServerHistory(const int size);
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
void CSeries::CSeries(void) : m_name(""),
|
||||
m_timeframe_flags(0),
|
||||
m_buffers_total(0),
|
||||
m_buffer_size(0),
|
||||
m_symbol(""),
|
||||
m_period(WRONG_VALUE),
|
||||
m_refresh_current(true)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CSeries::~CSeries(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Set buffer size |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CSeries::BufferResize(const int size)
|
||||
{
|
||||
//--- check history
|
||||
if(!CheckLoadHistory(size))
|
||||
{
|
||||
printf("failed to get %d bars for %s,%s",size,m_symbol,EnumToString(m_period));
|
||||
return(false);
|
||||
}
|
||||
//--- history is available
|
||||
m_buffer_size=size;
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Set symbol and period |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CSeries::SetSymbolPeriod(const string symbol,const ENUM_TIMEFRAMES period)
|
||||
{
|
||||
m_symbol=(symbol==NULL) ? ChartSymbol() : symbol;
|
||||
m_period=(period==0) ? ChartPeriod() : period;
|
||||
PeriodToTimeframeFlag(m_period);
|
||||
//---
|
||||
return(true);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Convert period to timeframe flag (similar to visibility flags) |
|
||||
//+------------------------------------------------------------------+
|
||||
void CSeries::PeriodToTimeframeFlag(const ENUM_TIMEFRAMES period)
|
||||
{
|
||||
static ENUM_TIMEFRAMES _p_int[]=
|
||||
{
|
||||
PERIOD_M1,PERIOD_M2,PERIOD_M3,PERIOD_M4,PERIOD_M5,PERIOD_M6,
|
||||
PERIOD_M10,PERIOD_M12,PERIOD_M15,PERIOD_M20,PERIOD_M30,
|
||||
PERIOD_H1,PERIOD_H2,PERIOD_H3,PERIOD_H4,PERIOD_H6,PERIOD_H8,PERIOD_H12,
|
||||
PERIOD_D1,PERIOD_W1,PERIOD_MN1
|
||||
};
|
||||
//--- cycle for all timeframes
|
||||
for(int i=0;i<ArraySize(_p_int);i++)
|
||||
if(period==_p_int[i])
|
||||
{
|
||||
//--- at the same time generate the flag of the working timeframe
|
||||
m_timeframe_flags=((int)1)<<i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Converting value of ENUM_TIMEFRAMES to string |
|
||||
//+------------------------------------------------------------------+
|
||||
string CSeries::PeriodDescription(const int val)
|
||||
{
|
||||
int i,frame;
|
||||
//--- arrays for conversion of ENUM_TIMEFRAMES to string
|
||||
static string _p_str[]=
|
||||
{
|
||||
"M1","M2","M3","M4","M5","M6","M10","M12","M15","M20","M30",
|
||||
"H1","H2","H3","H4","H6","H8","H12","D1","W1","MN","UNKNOWN"
|
||||
};
|
||||
static ENUM_TIMEFRAMES _p_int[]=
|
||||
{
|
||||
PERIOD_M1,PERIOD_M2,PERIOD_M3,PERIOD_M4,PERIOD_M5,PERIOD_M6,
|
||||
PERIOD_M10,PERIOD_M12,PERIOD_M15,PERIOD_M20,PERIOD_M30,
|
||||
PERIOD_H1,PERIOD_H2,PERIOD_H3,PERIOD_H4,PERIOD_H6,PERIOD_H8,PERIOD_H12,
|
||||
PERIOD_D1,PERIOD_W1,PERIOD_MN1
|
||||
};
|
||||
//--- check
|
||||
frame=(val==0)?m_period:val;
|
||||
if(frame==WRONG_VALUE)
|
||||
return("WRONG_VALUE");
|
||||
//--- cycle for all timeframes
|
||||
for(i=0;i<ArraySize(_p_int);i++)
|
||||
if(frame==_p_int[i])
|
||||
break;
|
||||
//---
|
||||
return(_p_str[i]);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Checks data by specified symbol's timeframe and |
|
||||
//| downloads it from server, if necessary |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CSeries::CheckLoadHistory(const int size)
|
||||
{
|
||||
//--- don't ask for load of its own data if it is an indicator
|
||||
if(MQLInfoInteger(MQL_PROGRAM_TYPE)==PROGRAM_INDICATOR && Period()==m_period && Symbol()==m_symbol)
|
||||
return(true);
|
||||
if(size>TerminalInfoInteger(TERMINAL_MAXBARS))
|
||||
{
|
||||
//--- Definitely won't have such amount of data
|
||||
printf(__FUNCTION__+": requested too much data (%d)",size);
|
||||
return(false);
|
||||
}
|
||||
m_first_date=0;
|
||||
if(CheckTerminalHistory(size))
|
||||
return(true);
|
||||
if(CheckServerHistory(size))
|
||||
return(true);
|
||||
//--- failed
|
||||
return(false);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Checks data in terminal |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CSeries::CheckTerminalHistory(const int size)
|
||||
{
|
||||
datetime times[1];
|
||||
long bars=0;
|
||||
//--- Enough data in timeseries?
|
||||
if(Bars(m_symbol,m_period)>=size)
|
||||
return(true);
|
||||
//--- second attempt
|
||||
if(SeriesInfoInteger(m_symbol,PERIOD_M1,SERIES_BARS_COUNT,bars))
|
||||
{
|
||||
//--- there is loaded data to build timeseries
|
||||
if(bars>size*PeriodSeconds(m_period)/60)
|
||||
{
|
||||
//--- force timeseries build
|
||||
CopyTime(m_symbol,m_period,size-1,1,times);
|
||||
//--- check date
|
||||
if(SeriesInfoInteger(m_symbol,m_period,SERIES_BARS_COUNT,bars))
|
||||
//--- Timeseries generated using data from terminal
|
||||
if(bars>size)
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
//--- failed
|
||||
return(false);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Downloads missing data from server |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CSeries::CheckServerHistory(const int size)
|
||||
{
|
||||
//--- load symbol history info
|
||||
long first_server_date=0;
|
||||
while(!SeriesInfoInteger(m_symbol,PERIOD_M1,SERIES_SERVER_FIRSTDATE,first_server_date) && !IsStopped())
|
||||
Sleep(5);
|
||||
//--- Enough data on server?
|
||||
if(first_server_date>TimeCurrent()-size*PeriodSeconds(m_period))
|
||||
return(false);
|
||||
//--- load data step by step
|
||||
int fail_cnt=0;
|
||||
datetime times[1];
|
||||
while(!IsStopped())
|
||||
{
|
||||
//--- wait for timeseries build
|
||||
while(!SeriesInfoInteger(m_symbol,m_period,SERIES_SYNCHRONIZED) && !IsStopped())
|
||||
Sleep(5);
|
||||
//--- ask for built bars
|
||||
int bars=Bars(m_symbol,m_period);
|
||||
if(bars>size)
|
||||
return(true);
|
||||
//--- copying of next part forces data loading
|
||||
if(CopyTime(m_symbol,m_period,size-1,1,times)==1)
|
||||
return(true);
|
||||
//--- no more than 100 failed attempts
|
||||
if(++fail_cnt>=100)
|
||||
return(false);
|
||||
Sleep(10);
|
||||
}
|
||||
//--- failed
|
||||
return(false);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CDoubleBuffer. |
|
||||
//| Purpose: Base class of buffer of data of the double type. |
|
||||
//| Derives from class CArrayDouble. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CDoubleBuffer : public CArrayDouble
|
||||
{
|
||||
protected:
|
||||
string m_symbol; // symbol
|
||||
ENUM_TIMEFRAMES m_period; // period
|
||||
int m_size; // size of used history
|
||||
|
||||
public:
|
||||
CDoubleBuffer(void);
|
||||
~CDoubleBuffer(void);
|
||||
//--- methods of access to protected data
|
||||
void Size(const int size) { m_size=size; }
|
||||
//--- methods of access to data
|
||||
double At(const int index) const;
|
||||
//--- method of refreshing of the data buffer
|
||||
virtual bool Refresh(void) { return(true); }
|
||||
virtual bool RefreshCurrent(void) { return(true); }
|
||||
//--- methods of tuning
|
||||
void SetSymbolPeriod(const string symbol,const ENUM_TIMEFRAMES period);
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CDoubleBuffer::CDoubleBuffer(void) : m_symbol(""),
|
||||
m_period(WRONG_VALUE),
|
||||
m_size(DEFAULT_BUFFER_SIZE)
|
||||
{
|
||||
ArraySetAsSeries(m_data,true);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CDoubleBuffer::~CDoubleBuffer(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Access to data in a specified position |
|
||||
//+------------------------------------------------------------------+
|
||||
double CDoubleBuffer::At(const int index) const
|
||||
{
|
||||
//--- check
|
||||
if(index>=m_data_total)
|
||||
return(EMPTY_VALUE);
|
||||
//---
|
||||
double d=CArrayDouble::At(index);
|
||||
//---
|
||||
return(d);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Set symbol and period |
|
||||
//+------------------------------------------------------------------+
|
||||
void CDoubleBuffer::SetSymbolPeriod(const string symbol,const ENUM_TIMEFRAMES period)
|
||||
{
|
||||
m_symbol=(symbol==NULL) ? ChartSymbol() : symbol;
|
||||
m_period=(period==0) ? ChartPeriod() : period;
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,424 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Volumes.mqh |
|
||||
//| Copyright 2000-2026, MetaQuotes Ltd. |
|
||||
//| www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#include "Indicator.mqh"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CiAD. |
|
||||
//| Purpose: Class of the "Accumulation/Distribution" indicator. |
|
||||
//| Derives from class CIndicator. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CiAD : public CIndicator
|
||||
{
|
||||
protected:
|
||||
ENUM_APPLIED_VOLUME m_applied; // applied volume
|
||||
|
||||
public:
|
||||
CiAD(void);
|
||||
~CiAD(void);
|
||||
//--- methods of access to protected data
|
||||
ENUM_APPLIED_VOLUME Applied(void) const { return(m_applied); }
|
||||
//--- method of creation
|
||||
bool Create(const string symbol,const ENUM_TIMEFRAMES period,const ENUM_APPLIED_VOLUME applied);
|
||||
//--- methods of access to indicator data
|
||||
double Main(const int index) const;
|
||||
//--- method of identifying
|
||||
virtual int Type(void) const { return(IND_AD); }
|
||||
|
||||
protected:
|
||||
//--- methods of tuning
|
||||
virtual bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[]);
|
||||
bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const ENUM_APPLIED_VOLUME applied);
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiAD::CiAD(void) : m_applied(WRONG_VALUE)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiAD::~CiAD(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Create the "Accumulation/Distribution" indicator |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiAD::Create(const string symbol,const ENUM_TIMEFRAMES period,const ENUM_APPLIED_VOLUME applied)
|
||||
{
|
||||
//--- check history
|
||||
if(!SetSymbolPeriod(symbol,period))
|
||||
return(false);
|
||||
//--- create
|
||||
m_handle=iAD(symbol,period,applied);
|
||||
//--- check result
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
return(false);
|
||||
//--- indicator successfully created
|
||||
if(!Initialize(symbol,period,applied))
|
||||
{
|
||||
//--- initialization failed
|
||||
IndicatorRelease(m_handle);
|
||||
m_handle=INVALID_HANDLE;
|
||||
return(false);
|
||||
}
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with universal parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiAD::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[])
|
||||
{
|
||||
return(Initialize(symbol,period,(ENUM_APPLIED_VOLUME)params[0].integer_value));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with special parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiAD::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const ENUM_APPLIED_VOLUME applied)
|
||||
{
|
||||
if(CreateBuffers(symbol,period,1))
|
||||
{
|
||||
//--- string of status of drawing
|
||||
m_name ="AD";
|
||||
m_status="("+symbol+","+PeriodDescription()+","+VolumeDescription(applied)+") H="+IntegerToString(m_handle);
|
||||
//--- save settings
|
||||
m_applied=applied;
|
||||
//--- create buffers
|
||||
((CIndicatorBuffer*)At(0)).Name("MAIN_LINE");
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//--- error
|
||||
return(false);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Access to buffer of "Accumulation/Distribution" |
|
||||
//+------------------------------------------------------------------+
|
||||
double CiAD::Main(const int index) const
|
||||
{
|
||||
CIndicatorBuffer *buffer=At(0);
|
||||
//--- check
|
||||
if(buffer==NULL)
|
||||
return(EMPTY_VALUE);
|
||||
//---
|
||||
return(buffer.At(index));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CiMFI. |
|
||||
//| Purpose: Class of the "Money Flow Index" indicator. |
|
||||
//| Derives from class CIndicator. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CiMFI : public CIndicator
|
||||
{
|
||||
protected:
|
||||
int m_ma_period;
|
||||
ENUM_APPLIED_VOLUME m_applied;
|
||||
|
||||
public:
|
||||
CiMFI(void);
|
||||
~CiMFI(void);
|
||||
//--- methods of access to protected data
|
||||
int MaPeriod(void) const { return(m_ma_period); }
|
||||
ENUM_APPLIED_VOLUME Applied(void) const { return(m_applied); }
|
||||
//--- method of creation
|
||||
bool Create(const string symbol,const ENUM_TIMEFRAMES period,
|
||||
const int ma_period,const ENUM_APPLIED_VOLUME applied);
|
||||
//--- methods of access to indicator data
|
||||
double Main(const int index) const;
|
||||
//--- method of identifying
|
||||
virtual int Type(void) const { return(IND_MFI); }
|
||||
|
||||
protected:
|
||||
//--- methods of tuning
|
||||
virtual bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[]);
|
||||
bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,
|
||||
const int ma_period,const ENUM_APPLIED_VOLUME applied);
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiMFI::CiMFI(void) : m_ma_period(-1),
|
||||
m_applied(WRONG_VALUE)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiMFI::~CiMFI(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Create the "Money Flow Index" indicator |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiMFI::Create(const string symbol,const ENUM_TIMEFRAMES period,
|
||||
const int ma_period,const ENUM_APPLIED_VOLUME applied)
|
||||
{
|
||||
//--- check history
|
||||
if(!SetSymbolPeriod(symbol,period))
|
||||
return(false);
|
||||
//--- create
|
||||
m_handle=iMFI(symbol,period,ma_period,applied);
|
||||
//--- check result
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
return(false);
|
||||
//--- indicator successfully created
|
||||
if(!Initialize(symbol,period,ma_period,applied))
|
||||
{
|
||||
//--- initialization failed
|
||||
IndicatorRelease(m_handle);
|
||||
m_handle=INVALID_HANDLE;
|
||||
return(false);
|
||||
}
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with universal parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiMFI::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[])
|
||||
{
|
||||
return(Initialize(symbol,period,(int)params[0].integer_value,(ENUM_APPLIED_VOLUME)params[1].integer_value));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with special parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiMFI::Initialize(const string symbol,const ENUM_TIMEFRAMES period,
|
||||
const int ma_period,const ENUM_APPLIED_VOLUME applied)
|
||||
{
|
||||
if(CreateBuffers(symbol,period,1))
|
||||
{
|
||||
//--- string of status of drawing
|
||||
m_name ="MFI";
|
||||
m_status="("+symbol+","+PeriodDescription()+","+
|
||||
IntegerToString(ma_period)+","+VolumeDescription(applied)+","+") H="+IntegerToString(m_handle);
|
||||
//--- save settings
|
||||
m_ma_period=ma_period;
|
||||
m_applied =applied;
|
||||
//--- create buffers
|
||||
((CIndicatorBuffer*)At(0)).Name("MAIN_LINE");
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//--- error
|
||||
return(false);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Access to buffer of "Money Flow Index" |
|
||||
//+------------------------------------------------------------------+
|
||||
double CiMFI::Main(const int index) const
|
||||
{
|
||||
CIndicatorBuffer *buffer=At(0);
|
||||
//--- check
|
||||
if(buffer==NULL)
|
||||
return(EMPTY_VALUE);
|
||||
//---
|
||||
return(buffer.At(index));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CiOBV. |
|
||||
//| Purpose: Class of the "On Balance Volume" indicator. |
|
||||
//| Derives from class CIndicator. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CiOBV : public CIndicator
|
||||
{
|
||||
protected:
|
||||
ENUM_APPLIED_VOLUME m_applied;
|
||||
|
||||
public:
|
||||
CiOBV(void);
|
||||
~CiOBV(void);
|
||||
//--- methods of access to protected data
|
||||
ENUM_APPLIED_VOLUME Applied(void) const { return(m_applied); }
|
||||
//--- method create
|
||||
bool Create(const string symbol,const ENUM_TIMEFRAMES period,const ENUM_APPLIED_VOLUME applied);
|
||||
//--- methods of access to indicator data
|
||||
double Main(const int index) const;
|
||||
//--- method of identifying
|
||||
virtual int Type(void) const { return(IND_OBV); }
|
||||
|
||||
protected:
|
||||
//--- methods of tuning
|
||||
virtual bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[]);
|
||||
bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const ENUM_APPLIED_VOLUME applied);
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiOBV::CiOBV(void) : m_applied(WRONG_VALUE)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiOBV::~CiOBV(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Create the "On Balance Volume" indicator |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiOBV::Create(const string symbol,const ENUM_TIMEFRAMES period,const ENUM_APPLIED_VOLUME applied)
|
||||
{
|
||||
//--- check history
|
||||
if(!SetSymbolPeriod(symbol,period))
|
||||
return(false);
|
||||
//--- create
|
||||
m_handle=iOBV(symbol,period,applied);
|
||||
//--- check result
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
return(false);
|
||||
//--- indicator successfully created
|
||||
if(!Initialize(symbol,period,applied))
|
||||
{
|
||||
//--- initialization failed
|
||||
IndicatorRelease(m_handle);
|
||||
m_handle=INVALID_HANDLE;
|
||||
return(false);
|
||||
}
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with universal parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiOBV::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[])
|
||||
{
|
||||
return(Initialize(symbol,period,(ENUM_APPLIED_VOLUME)params[0].integer_value));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with special parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiOBV::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const ENUM_APPLIED_VOLUME applied)
|
||||
{
|
||||
if(CreateBuffers(symbol,period,1))
|
||||
{
|
||||
//--- string of status of drawing
|
||||
m_name ="OBV";
|
||||
m_status="("+symbol+","+PeriodDescription()+","+VolumeDescription(applied)+","+") H="+IntegerToString(m_handle);
|
||||
//--- save settings
|
||||
m_applied=applied;
|
||||
//--- create buffers
|
||||
((CIndicatorBuffer*)At(0)).Name("MAIN_LINE");
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//--- error
|
||||
return(false);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Access to buffer of "On Balance Volume" |
|
||||
//+------------------------------------------------------------------+
|
||||
double CiOBV::Main(const int index) const
|
||||
{
|
||||
CIndicatorBuffer *buffer=At(0);
|
||||
//--- check
|
||||
if(buffer==NULL)
|
||||
return(EMPTY_VALUE);
|
||||
//---
|
||||
return(buffer.At(index));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CiVolumes. |
|
||||
//| Purpose: Class of the "Volumes" indicator. |
|
||||
//| Derives from class CIndicator. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CiVolumes : public CIndicator
|
||||
{
|
||||
protected:
|
||||
ENUM_APPLIED_VOLUME m_applied;
|
||||
|
||||
public:
|
||||
CiVolumes(void);
|
||||
~CiVolumes(void);
|
||||
//--- methods of access to protected data
|
||||
ENUM_APPLIED_VOLUME Applied(void) const { return(m_applied); }
|
||||
//--- method create
|
||||
bool Create(const string symbol,const ENUM_TIMEFRAMES period,const ENUM_APPLIED_VOLUME applied);
|
||||
//--- methods of access to indicator data
|
||||
double Main(const int index) const;
|
||||
//--- method of identifying
|
||||
virtual int Type(void) const { return(IND_VOLUMES); }
|
||||
|
||||
protected:
|
||||
//--- methods of tuning
|
||||
virtual bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[]);
|
||||
bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const ENUM_APPLIED_VOLUME applied);
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiVolumes::CiVolumes(void) : m_applied(WRONG_VALUE)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CiVolumes::~CiVolumes(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Create the "Volumes" indicator |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiVolumes::Create(const string symbol,const ENUM_TIMEFRAMES period,const ENUM_APPLIED_VOLUME applied)
|
||||
{
|
||||
//--- check history
|
||||
if(!SetSymbolPeriod(symbol,period))
|
||||
return(false);
|
||||
//--- create
|
||||
m_handle=iVolumes(symbol,period,applied);
|
||||
//--- check result
|
||||
if(m_handle==INVALID_HANDLE)
|
||||
return(false);
|
||||
//--- indicator successfully created
|
||||
if(!Initialize(symbol,period,applied))
|
||||
{
|
||||
//--- initialization failed
|
||||
IndicatorRelease(m_handle);
|
||||
m_handle=INVALID_HANDLE;
|
||||
return(false);
|
||||
}
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with universal parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiVolumes::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[])
|
||||
{
|
||||
return(Initialize(symbol,period,(ENUM_APPLIED_VOLUME)params[0].integer_value));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialize the indicator with special parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
bool CiVolumes::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const ENUM_APPLIED_VOLUME applied)
|
||||
{
|
||||
if(CreateBuffers(symbol,period,1))
|
||||
{
|
||||
//--- string of status of drawing
|
||||
m_name ="Volumes";
|
||||
m_status="("+symbol+","+PeriodDescription()+","+VolumeDescription(applied)+","+") H="+IntegerToString(m_handle);
|
||||
//--- save settings
|
||||
m_applied=applied;
|
||||
//--- create buffers
|
||||
((CIndicatorBuffer*)At(0)).Name("MAIN_LINE");
|
||||
//--- ok
|
||||
return(true);
|
||||
}
|
||||
//--- error
|
||||
return(false);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Access to buffer of "Volumes" |
|
||||
//+------------------------------------------------------------------+
|
||||
double CiVolumes::Main(const int index) const
|
||||
{
|
||||
CIndicatorBuffer *buffer=At(0);
|
||||
//--- check
|
||||
if(buffer==NULL)
|
||||
return(EMPTY_VALUE);
|
||||
//---
|
||||
return(buffer.At(index));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
Reference in New Issue
Block a user