المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : مؤشر بسيط



سابليس
26-10-2018, 03:47 PM
السلام عليكم ورحمة الله وبركاته
استاذ حسن لو تكرمت برمجة مؤشر يلون الشموع بناء على مؤشر force index
اذا كان خط المؤشر صاعد تتلون الشموع بالاخضر واذا كان هابط تتلون بالاحمر

//+------------------------------------------------------------------+
//| Class CiForce. |
//| Purpose: Class of the "Force Index" indicator. |
//| Derives from class CIndicator. |
//+------------------------------------------------------------------+
class CiForce : public CIndicator
{
protected:
int m_ma_period;
ENUM_MA_METHOD m_ma_method;
ENUM_APPLIED_PRICE m_applied;


public:
CiForce(void);
~CiForce(void);
//--- methods of access to protected data
int MaPeriod(void) const { return(m_ma_period); }
ENUM_MA_METHOD MaMethod(void) const { return(m_ma_method); }
ENUM_APPLIED_PRICE Applied(void) const { return(m_applied); }
//--- method of creation
bool Create(const string symbol,const ENUM_TIMEFRAMES period,
const int ma_period,const ENUM_MA_METHOD ma_method,const ENUM_APPLIED_PRICE applied);
//--- methods of access to indicator data
virtual double GetData(const int buffer_num,const int index) const;
double Main(const int index) const;
//--- method of identifying
virtual int Type(void) const { return(IND_FORCE); }


protected:
//--- methods of tuning
virtual bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam &params[]);
bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,
const int ma_period,const ENUM_MA_METHOD ma_method,const ENUM_APPLIED_PRICE applied);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CiForce::CiForce(void) : m_ma_period(-1),
m_ma_method(-1),
m_applied(-1)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CiForce::~CiForce(void)
{
}
//+------------------------------------------------------------------+
//| Create indicator "Force Index" |
//+------------------------------------------------------------------+
bool CiForce::Create(const string symbol,const ENUM_TIMEFRAMES period,
const int ma_period,const ENUM_MA_METHOD ma_method,const ENUM_APPLIED_PRICE applied)
{
SetSymbolPeriod(symbol,period);
//--- result of initialization
return(Initialize(symbol,period,ma_period,ma_metho d,applied));
}
//+------------------------------------------------------------------+
//| Initialize the indicator with universal parameters |
//+------------------------------------------------------------------+
bool CiForce::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam &params[])
{
return(Initialize(symbol,period,(int)params[0].integer_value,(ENUM_MA_METHOD)params[1].integer_value,
(ENUM_APPLIED_PRICE)params[2].integer_value));
}
//+------------------------------------------------------------------+
//| Initialize the indicator with special parameters |
//+------------------------------------------------------------------+
bool CiForce::Initialize(const string symbol,const ENUM_TIMEFRAMES period,
const int ma_period,const ENUM_MA_METHOD ma_method,const ENUM_APPLIED_PRICE applied)
{
m_name="Force";
//--- save settings
m_ma_period=ma_period;
m_ma_method=ma_method;
m_applied =applied;
//--- ok
return(true);
}
//+------------------------------------------------------------------+
//| Access to buffer of "Force Index" |
//+------------------------------------------------------------------+
double CiForce::GetData(const int buffer_num,const int index) const
{
return(iForce(m_symbol,m_period,m_ma_period,m_ma_m ethod,m_applied,index));
}
//+------------------------------------------------------------------+
//| Access to buffer of "Force Index" |
//+------------------------------------------------------------------+
double CiForce::Main(const int index) const
{
return(GetData(0,index));
}
//+------------------------------------------------------------------+

kira-h
28-10-2018, 09:23 PM
وعليكم السلام
مرفق المؤشر