//+------------------------------------------------------------------+ //| channel_breakout_entry_HTF.mq5 | //| Copyright © 2015, Nikolay Kositsin | //| Khabarovsk, farria@mail.redcom.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2015, Nikolay Kositsin" #property link "farria@mail.redcom.ru" //--- номер версии индикатора #property version "1.00" //---- отрисовка индикатора в главном окне #property indicator_chart_window //---- количество индикаторных буферов 8 #property indicator_buffers 8 //---- использовано всего 8 графических построений #property indicator_plots 8 //+----------------------------------------------+ //| Объявление констант | //+----------------------------------------------+ #define RESET 0 // константа для возврата терминалу команды на пересчет индикатора #define INDICATOR_NAME "channel_breakout_entry" // константа для имени индикатора #define SIZE 8 // константа для количества вызовов функции CountLine //+----------------------------------------------+ //| Параметры отрисовки индикатора | //+----------------------------------------------+ //---- отрисовка уровней в виде линий #property indicator_type1 DRAW_LINE #property indicator_type2 DRAW_LINE #property indicator_type3 DRAW_LINE #property indicator_type4 DRAW_LINE #property indicator_type5 DRAW_LINE #property indicator_type6 DRAW_LINE #property indicator_type7 DRAW_LINE #property indicator_type8 DRAW_LINE //---- выбор цветов уровней #property indicator_color1 clrDarkGray #property indicator_color2 clrDarkGray #property indicator_color3 clrDodgerBlue #property indicator_color4 clrDodgerBlue #property indicator_color5 clrTomato #property indicator_color6 clrTomato #property indicator_color7 clrLightSkyBlue #property indicator_color8 clrPlum //---- уровни - сплошные кривые #property indicator_style1 STYLE_SOLID #property indicator_style2 STYLE_SOLID #property indicator_style3 STYLE_SOLID #property indicator_style4 STYLE_SOLID #property indicator_style5 STYLE_SOLID #property indicator_style6 STYLE_SOLID #property indicator_style7 STYLE_SOLID #property indicator_style8 STYLE_SOLID //---- толщина уровней равна 2 #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 2 #property indicator_width4 2 #property indicator_width5 2 #property indicator_width6 2 #property indicator_width7 2 #property indicator_width8 2 //---- отображение меток уровней #property indicator_label1 "trailing_Up" #property indicator_label2 "trailing_Dn" #property indicator_label3 "sys1_Up" #property indicator_label4 "sys1_Dn" #property indicator_label5 "failsafe_Up" #property indicator_label6 "failsafe_Dn" #property indicator_label7 "Sys 1 Stp" #property indicator_label8 "Sys 2 Stp" //+-------------------------------------+ //| Входные параметры индикатора | //+-------------------------------------+ input ENUM_TIMEFRAMES TimeFrame=PERIOD_H4; // Период графика input uint Range1=10; input uint Range2=20; input uint Range3=55; input double atr_factor=2; input int atr_range=14; input int Shift=0; // Сдвиг индикатора по горизонтали в барах //+-------------------------------------+ //---- объявление динамических массивов, которые будут в //---- дальнейшем использованы в качестве индикаторных буферов уровней channel_breakout_entry double ExtLineBuffer1[],ExtLineBuffer2[],ExtLineBuffer3[],ExtLineBuffer4[]; double ExtLineBuffer5[],ExtLineBuffer6[],ExtLineBuffer7[],ExtLineBuffer8[]; //--- объявление строковых переменных string Symbol_,Word; //--- объявление целочисленных переменных начала отсчета данных int min_rates_total; //--- объявление целочисленных переменных для хендлов индикаторов int Ind_Handle; //+------------------------------------------------------------------+ //| Получение таймфрейма в виде строки | //+------------------------------------------------------------------+ string GetStringTimeframe(ENUM_TIMEFRAMES timeframe) {return(StringSubstr(EnumToString(timeframe),7,-1));} //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- проверка периодов графиков на корректность if(TimeFrameRates_Total || Prev_Calculated<=0)// проверка на первый старт расчета индикатора { limit=Rates_Total-Min_Rates_Total-1; // стартовый номер для расчета всех баров LastCountBar[Numb]=limit; } else limit=LastCountBar[Numb]+Rates_Total-Prev_Calculated; // стартовый номер для расчета новых баров //--- основной цикл расчета индикатора for(int bar=limit; bar>=0 && !IsStopped(); bar--) { //--- обнулим содержимое индикаторных буферов до расчета IndBuf[bar]=0.0; //--- копируем вновь появившиеся данные в массив IndTime if(CopyTime(Symbol_,TimeFrame,iTime[bar],1,IndTime)<=0) return(RESET); //--- if(iTime[bar]>=IndTime[0] && iTime[bar+1]