//+------------------------------------------------------------------+ //| 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