//+------------------------------------------------------------------+ //| MultiSymbol.mq5 | //| Copyright 2018, pipPod. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2018, pipPod." #property link "https://www.mql5.com/en/users/pippod" #property description"Multi Symbol" #property version "1.10" #property strict #property indicator_separate_window #property indicator_buffers 20 //Inc/dec by factor 5 #property indicator_plots 4 //--- #property indicator_type1 DRAW_COLOR_CANDLES #property indicator_color1 clrRoyalBlue,clrLimeGreen,clrFireBrick //--- #property indicator_type2 DRAW_COLOR_CANDLES #property indicator_color2 clrSilver,clrLimeGreen,clrFireBrick //--- #property indicator_type3 DRAW_COLOR_CANDLES #property indicator_color3 clrLimeGreen,clrFireBrick,clrYellow //--- #property indicator_type4 DRAW_COLOR_CANDLES #property indicator_color4 clrLimeGreen,clrYellow,clrFireBrick //--- //+------------------------------------------------------------------+ //| Class for indicator and index buffers | //+------------------------------------------------------------------+ class CSymbol { private: int m_handle; //--- buffers double m_open[]; double m_high[]; double m_low[]; double m_close[]; double m_color[]; public: //--- constructor CSymbol(void):m_handle(INVALID_HANDLE) { this.ArraySetAsSeries(true); } //--- destructor ~CSymbol(void) { IndicatorRelease(m_handle); } //--- indicator handle int Handle(int handle) { return(m_handle=handle); } //--- copy symbol/indicator data int CopyBuffer(const int start,const int count) { int copied; if((copied=::CopyBuffer(m_handle,0,start,count,m_open))<1 || (copied=::CopyBuffer(m_handle,1,start,count,m_high))<1 || (copied=::CopyBuffer(m_handle,2,start,count,m_low))<1 || (copied=::CopyBuffer(m_handle,3,start,count,m_close))<1 || (copied=::CopyBuffer(m_handle,4,start,count,m_color))<1) return(-1); return(copied); } //--- previously calculated bars int BarsCalculated(void) { return(BarsCalculated(m_handle)); } //--- assign index buffers bool SetIndexBuffer(int index) { return(SetIndexBuffer(index,m_open) && SetIndexBuffer(index+1,m_high) && SetIndexBuffer(index+2,m_low) && SetIndexBuffer(index+3,m_close) && SetIndexBuffer(index+4,m_color,INDICATOR_COLOR_INDEX)); } //--- index buffer series flag bool ArraySetAsSeries(bool flag) { return(ArraySetAsSeries(m_open,flag) && ArraySetAsSeries(m_high,flag) && ArraySetAsSeries(m_low,flag) && ArraySetAsSeries(m_close,flag) && ArraySetAsSeries(m_color,flag)); } //--- initialize index buffers bool ArrayInitialize(double value) { return(ArrayInitialize(m_open,value) && ArrayInitialize(m_high,value) && ArrayInitialize(m_low,value) && ArrayInitialize(m_close,value) && ArrayInitialize(m_color,value)); } //--- detach index buffers void ArrayFree(void) { ArrayFree(m_open); ArrayFree(m_high); ArrayFree(m_low); ArrayFree(m_close); ArrayFree(m_color); } }; //+------------------------------------------------------------------+ //| Symbols to display | //+------------------------------------------------------------------+ input string Symbol1="EURUSD"; //Symbol 1 input string Symbol2="GBPUSD"; //Symbol 2 input string Symbol3="USDCHF"; //Symbol 3 input string Symbol4="USDJPY"; //Symbol 4 //--- indicator and index objects CSymbol *symbol[indicator_plots]; //--- chart properties long chartID; short window; int toCopy; //--- symbols for indicators string Symbol[indicator_plots]; //int Handle[indicator_plots]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { IndicatorSetInteger(0,INDICATOR_DIGITS,4); chartID=ChartID(); //--- set indicator symbols Symbol[0]=Symbol1; Symbol[1]=Symbol2; Symbol[2]=Symbol3; Symbol[3]=Symbol4; for(int i=0;i=CHARTEVENT_CUSTOM) OnTick((int)lparam,(bool)dparam?toCopy:1); //--- } //+-------------------------------------------------------------------+ //| Create coloured symbol labels | //+-------------------------------------------------------------------+ void CreateLabels() { //---names to show string Label[indicator_plots*2]; color Color[indicator_plots*2]={clrNONE}; for(int i=0,j=0,k=1;i