//+------------------------------------------------------------------+ //| FORTS_Currency_Power.mq5 | //| Copyright 2017, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2017, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #define MINITE_BARS_COUNT 5 #include #include //+------------------------------------------------------------------+ //| IndexData | //+------------------------------------------------------------------+ struct IndexData { string symbol; double values[]; }; //+------------------------------------------------------------------+ //| CPowersFORTS | //+------------------------------------------------------------------+ class CPowersFORTS { protected: CCurrencyPowerIndex m_indices[3]; IndexData m_data[3]; CGraphic m_graph_powers; //-- double m_values_50[]; double m_values_RTS[]; double m_values_USD[]; double m_values_RUB[]; //--- internal variables for circular buffer int m_size; int m_head; int m_tail; int m_count; //--- void AddCurrentData(); bool GetDataArray(const int idx,double &values[]); bool m_initialized; public: void CPowersFORTS::CPowersFORTS(); bool Initialize(const int minute_bars_count=5); void Calculate(); bool ShowCurrencyPowers(); }; //+------------------------------------------------------------------+ //| Class constructor | //+------------------------------------------------------------------+ void CPowersFORTS::CPowersFORTS() { m_size=400; m_head=0; m_tail=0; m_count=0; m_initialized=false; //--- for(int i=0; i<3; i++) ArrayResize(m_data[i].values,m_size); } //+------------------------------------------------------------------+ //| Calculate | //+------------------------------------------------------------------+ void CPowersFORTS::Calculate() { for(int i=0; i<3; i++) m_indices[i].TickCalculate(); //--- AddCurrentData(); } //+------------------------------------------------------------------+ //| AddCurrentData | //+------------------------------------------------------------------+ void CPowersFORTS::AddCurrentData() { for(int i=0; i<3; i++) { double value=m_indices[i].GetCurrentPriceAverage(); m_data[i].values[m_tail]=value; } m_tail=(m_tail+1)%m_size; if(m_tail==m_head) m_head=(m_head+1)%m_size; m_count++; if(m_count>m_size-1) m_count=m_size-1; } //+------------------------------------------------------------------+ //| GetDataArray | //+------------------------------------------------------------------+ bool CPowersFORTS::GetDataArray(const int idx,double &values[]) { //--- check array index if(idx<0 || idx>3) return(false); //--- if(ArraySize(values)