//+------------------------------------------------------------------+ //| #MTF Supertrend line.mq4 | //| Copyright © 2006, Eli hayun | //| http://www.elihayun.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2006, Eli hayun" #property link "http://www.elihayun.com" #property indicator_chart_window #property indicator_buffers 8 #property indicator_color1 Red #property indicator_color2 Blue #property indicator_color3 Red #property indicator_color4 Blue #property indicator_color5 Red #property indicator_color6 Blue #property indicator_color7 Red #property indicator_color8 Blue //---- buffers double buf_up1D[]; double buf_down1D[]; double buf_up4H[]; double buf_down4H[]; double buf_up1H[]; double buf_down1H[]; double buf_up30M[]; double buf_down30M[]; extern int Period_1 = PERIOD_M15; extern int Period_2 = PERIOD_M30; extern int Period_3 = PERIOD_H1; extern int Period_4 = PERIOD_H4; extern bool AutoDisplay = true; extern bool display_Period_1 = true; extern bool display_Period_2 = true; extern bool display_Period_3 = true; extern bool display_Period_4 = true; extern bool Play_Sound = true; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators if (AutoDisplay) { display_Period_1 = false; display_Period_2 = false; display_Period_3 = false; display_Period_4 = false; switch (Period()) { case PERIOD_M1 : SetValues(PERIOD_M1, PERIOD_M5, PERIOD_M15,PERIOD_M30, true, true, false, false); break; case PERIOD_M5 : SetValues(PERIOD_M5, PERIOD_M15,PERIOD_M30,PERIOD_H1, true, true, false, false); break; case PERIOD_M15 : SetValues(PERIOD_M5, PERIOD_M15,PERIOD_M30,PERIOD_H1, true, true, true, false); break; case PERIOD_M30 : SetValues(PERIOD_M5, PERIOD_M15,PERIOD_M30,PERIOD_H1, false, true, true, false); break; case PERIOD_H1 : SetValues(PERIOD_M15, PERIOD_M30,PERIOD_H1, PERIOD_H4, false, false, true, true); break; case PERIOD_H4 : SetValues(PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1, false, true, true, true); break; case PERIOD_D1 : SetValues(PERIOD_H1, PERIOD_H4, PERIOD_D1, PERIOD_W1, true, true, true, false); break; case PERIOD_W1 : SetValues(PERIOD_H4, PERIOD_D1, PERIOD_W1, PERIOD_MN1, false, true, true, false); break; case PERIOD_MN1 : SetValues(PERIOD_H4, PERIOD_D1, PERIOD_W1, PERIOD_MN1, false, false, true, true); break; } } int draw = DRAW_LINE; if (!display_Period_4) draw = DRAW_NONE; SetIndexStyle(0,draw, STYLE_SOLID, 4); SetIndexBuffer(0,buf_up1D); SetIndexStyle(1,draw, STYLE_SOLID, 4); SetIndexBuffer(1,buf_down1D); SetIndexLabel(0, tf2txt(Period_4)); SetIndexLabel(1, tf2txt(Period_4)); draw = DRAW_LINE; if (!display_Period_3) draw = DRAW_NONE; SetIndexStyle(2,draw, STYLE_SOLID, 3); SetIndexBuffer(2,buf_up4H); SetIndexStyle(3,draw, STYLE_SOLID, 3); SetIndexBuffer(3,buf_down4H); SetIndexLabel(2, tf2txt(Period_3)); SetIndexLabel(3, tf2txt(Period_3)); draw = DRAW_LINE; if (!display_Period_2) draw = DRAW_NONE; SetIndexStyle(4,draw, STYLE_SOLID, 2); SetIndexBuffer(4,buf_up1H); SetIndexStyle(5,draw, STYLE_SOLID, 2); SetIndexBuffer(5,buf_down1H); SetIndexLabel(4, tf2txt(Period_2)); SetIndexLabel(5, tf2txt(Period_2)); draw = DRAW_LINE; if (!display_Period_1) draw = DRAW_NONE; SetIndexStyle(6,draw, STYLE_SOLID, 1); SetIndexBuffer(6,buf_up30M); SetIndexStyle(7,draw, STYLE_SOLID, 1); SetIndexBuffer(7,buf_down30M); SetIndexLabel(6, tf2txt(Period_1)); SetIndexLabel(7, tf2txt(Period_1)); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); int i=0, y1d=0, y4h=0, y1h=0, y30m=0; int limit=Bars-counted_bars; datetime TimeArray_1D[] ,TimeArray_4H[], TimeArray_1H[], TimeArray_30M[]; //---- ArrayCopySeries(TimeArray_1D,MODE_TIME,Symbol(),Period_4); ArrayCopySeries(TimeArray_4H,MODE_TIME,Symbol(),Period_3); ArrayCopySeries(TimeArray_1H,MODE_TIME,Symbol(),Period_2); ArrayCopySeries(TimeArray_30M,MODE_TIME,Symbol(),Period_1); for(i=0, y1d=0, y4h=0, y1h=0, y30m=0;i