HMR_MULTI_Indicator

Author: Copyright � 2010, AlexHammer
Price Data Components
Series array that contains close prices for each bar
0 Views
0 Downloads
0 Favorites
HMR_MULTI_Indicator
//+------------------------------------------------------------------+
//|                                          HMR MULTI Indicator.mq4 |
//| Ìóëüòèâàëþòíûé èíäèêàòîð                                         |
//|   Äëÿ òîãî ÷òîáû êîððåêòíî ìàñøòàáèðîâàëèñü ãðàôèêè,ïðèõîäèòñÿ   |  
//|   ïåðåðèñîâûâàòü ãðàôèêè,íî íå ïîëíîñòüþ,à òîëüêî âèäèìóþ îáëàñü,|
//|   ïîýòîìó ïîäòîðìàæèâàåò.                                        |   
//|                                                                  |   
//|                                     Copyright © 2010, AlexHammer |
//|                                               hammerxp@pochta.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, AlexHammer"
#property link      "hammerxp@pochta.ru"

#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 Yellow
#property indicator_color2 Aqua
#property indicator_color3 Blue
#property indicator_color4 Red
#property indicator_color5 White
#property indicator_color6 Magenta
#property indicator_color7 Lime
#property indicator_color8 Indigo

extern string S1 = "EURUSD";  
extern string S2 = "EURJPY";  
extern string S3 = "EURCAD";  
extern string S4 = "AUDUSD";  
extern string S5 = "GBPUSD";  
extern string S6 = "USDJPY";  
extern string S7 = "USDCHF";  
extern string S8 = "USDCAD";
//ïåðåìåííûå îáúÿâëÿåì ñðàçó,÷òîáû ïîñòîÿííî íå ñîçäàâàëèñü (îïòèìèçàöèÿ)
double Buff1[],Buff2[],Buff3[],Buff4[],Buff5[],Buff6[],Buff7[],Buff8[],
       x1,x2,x3,x4,x5,x6,x7,x8;
int    BarsOnScreen,LeftBar,RightBar,i;
bool   _init;
string name = "HMR MULTI Indicator";     
//+------------------------------------------------------------------+
int init()
  {
   _init = false;
   IndicatorBuffers(8);
   //Åñëè ñèìâîë ãðàôèêà ñîâïàäàåò ñ ñèìâîëîì ïðîðèñîâêè,íàðèñóåì ëèíèþ òîëùå
   if (Symbol()==S1) i=3;else i=1;
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,i,indicator_color1); SetIndexBuffer(0,Buff1);
   if (Symbol()==S2) i=3;else i=1;
   SetIndexStyle (1,DRAW_LINE,STYLE_SOLID,i,indicator_color2); SetIndexBuffer(1,Buff2);
   if (Symbol()==S3) i=3;else i=1;
   SetIndexStyle (2,DRAW_LINE,STYLE_SOLID,i,indicator_color3); SetIndexBuffer(2,Buff3);
   if (Symbol()==S4) i=3;else i=1;
   SetIndexStyle (3,DRAW_LINE,STYLE_SOLID,i,indicator_color4); SetIndexBuffer(3,Buff4);
   if (Symbol()==S5) i=3;else i=1;
   SetIndexStyle (4,DRAW_LINE,STYLE_SOLID,i,indicator_color5); SetIndexBuffer(4,Buff5);
   if (Symbol()==S6) i=3;else i=1;
   SetIndexStyle (5,DRAW_LINE,STYLE_SOLID,i,indicator_color6); SetIndexBuffer(5,Buff6);
   if (Symbol()==S7) i=3;else i=1;
   SetIndexStyle (6,DRAW_LINE,STYLE_SOLID,i,indicator_color7); SetIndexBuffer(6,Buff7);
   if (Symbol()==S8) i=3;else i=1;
   SetIndexStyle (7,DRAW_LINE,STYLE_SOLID,i,indicator_color8); SetIndexBuffer(7,Buff8);
  return(0);
  }
//+------------------------------------------------------------------+
int deinit()
  {
  ObjectsDeleteAll();  
  return(0);
  }
//+------------------------------------------------------------------+
int start()
{
      if (!_init) MyInit();
      BarsOnScreen = WindowBarsPerChart()+1;
      LeftBar = WindowFirstVisibleBar();
      RightBar = LeftBar-BarsOnScreen;
      if (RightBar<0) RightBar=0;
       //Ïðîâåðÿåì åñòü ëè èñòîðèÿ áàðîâ äëÿ ïðîðèñîâêè
      if (LeftBar>iBars(S1,0) || LeftBar>iBars(S2,0) || LeftBar>iBars(S3,0) || LeftBar>iBars(S4,0) ||
          LeftBar>iBars(S5,0) || LeftBar>iBars(S6,0) || LeftBar>iBars(S7,0) || LeftBar>iBars(S8,0)) return;
       //Âûíîñèì èç öèêëà,÷òîáû óìåíüøèòü ðàñ÷¸òû (îïòèìèçàöèÿ)
       x1=iClose(S1,0,iHighest(S1,0,MODE_CLOSE,BarsOnScreen,RightBar));
       x2=iClose(S2,0,iHighest(S2,0,MODE_CLOSE,BarsOnScreen,RightBar));
       x3=iClose(S3,0,iHighest(S3,0,MODE_CLOSE,BarsOnScreen,RightBar));  
       x4=iClose(S4,0,iHighest(S4,0,MODE_CLOSE,BarsOnScreen,RightBar));
       x5=iClose(S5,0,iHighest(S5,0,MODE_CLOSE,BarsOnScreen,RightBar));
       x6=iClose(S6,0,iHighest(S6,0,MODE_CLOSE,BarsOnScreen,RightBar));
       x7=iClose(S7,0,iHighest(S7,0,MODE_CLOSE,BarsOnScreen,RightBar));
       x8=iClose(S8,0,iHighest(S8,0,MODE_CLOSE,BarsOnScreen,RightBar));
       for(i=RightBar; i<LeftBar; i++)
        {       
         Buff1[i] = iClose(S1,0, i)/x1;
         Buff2[i] = iClose(S2,0, i)/x2;
         Buff3[i] = iClose(S3,0, i)/x3;  
         Buff4[i] = iClose(S4,0, i)/x4;
         Buff5[i] = iClose(S5,0, i)/x5;
         Buff6[i] = iClose(S6,0, i)/x6;
         Buff7[i] = iClose(S7,0, i)/x7;
         Buff8[i] = iClose(S8,0, i)/x8;
        }
return(0);
}   
//+------------------------------------------------------------------+
void MyInit ()
{
   //Ïîäìåíÿåì èìÿ èíäèêàòîðà ÷òîáû ïîëó÷èòü óíèêàëüíûé íîìåð îêíà
   string label = GetTickCount();
   IndicatorShortName(label);
   int win = WindowFind(label);
   //Âîññòàíàâëèâàåì èìÿ èíäèêàòîðà
   IndicatorShortName(name);
   //---- labels    
   ObjectCreate("L1"+label,OBJ_LABEL,win,0,0,0,0);
   ObjectSet("L1"+label,OBJPROP_XDISTANCE,10);
   ObjectSet("L1"+label,OBJPROP_YDISTANCE,12);
   ObjectSetText("L1"+label,S1,10,"Tahoma",indicator_color1);
   ObjectCreate("L2"+label,OBJ_LABEL,win,0,0,0,0);
   ObjectSet("L2"+label,OBJPROP_XDISTANCE,10);
   ObjectSet("L2"+label,OBJPROP_YDISTANCE,24);
   ObjectSetText("L2"+label,S2,10,"Tahoma",indicator_color2);
   ObjectCreate("L3"+label,OBJ_LABEL,win,0,0,0,0);
   ObjectSet("L3"+label,OBJPROP_XDISTANCE,10);
   ObjectSet("L3"+label,OBJPROP_YDISTANCE,36);
   ObjectSetText("L3"+label,S3,10,"Tahoma",indicator_color3);
   ObjectCreate("L4"+label,OBJ_LABEL,win,0,0,0,0);
   ObjectSet("L4"+label,OBJPROP_XDISTANCE,10);
   ObjectSet("L4"+label,OBJPROP_YDISTANCE,48);
   ObjectSetText("L4"+label,S4,10,"Tahoma",indicator_color4);
   ObjectCreate("L5"+label,OBJ_LABEL,win,0,0,0,0);
   ObjectSet("L5"+label,OBJPROP_XDISTANCE,10);
   ObjectSet("L5"+label,OBJPROP_YDISTANCE,60);
   ObjectSetText("L5"+label,S5,10,"Tahoma",indicator_color5);   
   ObjectCreate("L6"+label,OBJ_LABEL,win,0,0,0,0);
   ObjectSet("L6"+label,OBJPROP_XDISTANCE,10);
   ObjectSet("L6"+label,OBJPROP_YDISTANCE,72);
   ObjectSetText("L6"+label,S6,10,"Tahoma",indicator_color6);
   ObjectCreate("L7"+label,OBJ_LABEL,win,0,0,0,0);
   ObjectSet("L7"+label,OBJPROP_XDISTANCE,10);
   ObjectSet("L7"+label,OBJPROP_YDISTANCE,84);
   ObjectSetText("L7"+label,S7,10,"Tahoma",indicator_color7);
   ObjectCreate("L8"+label,OBJ_LABEL,win,0,0,0,0);
   ObjectSet("L8"+label,OBJPROP_XDISTANCE,10);
   ObjectSet("L8"+label,OBJPROP_YDISTANCE,96);
   ObjectSetText("L8"+label,S8,10,"Tahoma",indicator_color8);
   WindowRedraw();
   _init = true;
}

Comments