//+------------------------------------------------------------------+ //| Ozymandias_Extended_HTF (PunkBASSter's edition).mq5 | //+------------------------------------------------------------------+ #property description "Ozymandias с возможностью изменения ТФ и параметров канала" //--- #property indicator_chart_window #property indicator_buffers 4 #property indicator_plots 3 #property indicator_type1 DRAW_COLOR_LINE #property indicator_type2 DRAW_LINE #property indicator_type3 DRAW_LINE //--- #property indicator_style1 STYLE_SOLID #property indicator_style2 STYLE_SOLID #property indicator_style3 STYLE_SOLID //--- #property indicator_color1 clrDeepPink,clrDodgerBlue #property indicator_color2 clrRosyBrown #property indicator_color3 clrRosyBrown //--- #property indicator_width1 3 #property indicator_width2 2 #property indicator_width3 2 //--- #property indicator_label1 "Ozymandias" #property indicator_label2 "Upper Ozymandias" #property indicator_label3 "Lower Ozymandias" //--- #define RESET 0 #define INDICATOR_NAME "Ozymandias" #define SIZE 1 //--- input ENUM_TIMEFRAMES TimeFrame=PERIOD_H4; input uint Length=2; input ENUM_MA_METHOD MAType=MODE_SMA; input int Shift=0; input double ChannelRatio=1; //ChannelAtrMultiplier input int AtrPeriod=100; //--- double UpIndBuffer[]; double DnIndBuffer[]; double IndBuffer[]; double ColorIndBuffer[]; //--- 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(!TimeFramesCheck(INDICATOR_NAME,TimeFrame)) return(INIT_FAILED); //--- min_rates_total=2; //--- Ind_Handle=iCustom(Symbol(),TimeFrame,"Ozymandias_Extended",Length,MAType,0,ChannelRatio,AtrPeriod); if(Ind_Handle==INVALID_HANDLE) { Print(" Не удалось получить хендл индикатора Ozymandias"); return(INIT_FAILED); } IndInit(0,IndBuffer,INDICATOR_DATA); IndInit(1,ColorIndBuffer,INDICATOR_COLOR_INDEX); IndInit(2,UpIndBuffer,INDICATOR_DATA); IndInit(3,DnIndBuffer,INDICATOR_DATA); //--- инициализация индикаторов PlotInit(0,EMPTY_VALUE,0,Shift); PlotInit(1,EMPTY_VALUE,0,Shift); PlotInit(2,EMPTY_VALUE,0,Shift); //--- создание имени для отображения в отдельном подокне и во всплывающей подсказке string shortname; StringConcatenate(shortname,INDICATOR_NAME,"(",GetStringTimeframe(TimeFrame),")"); IndicatorSetString(INDICATOR_SHORTNAME,shortname); IndicatorSetInteger(INDICATOR_DIGITS,_Digits); //--- завершение инициализации return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, // количество истории в барах на текущем тике const int prev_calculated,// количество истории в барах на предыдущем тике const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { if(rates_totalRates_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--) { //--- копируем вновь появившиеся данные в массив IndTime if(CopyTime(Symbol(),TFrame,iTime[bar],1,IndTime)<=0) return(RESET); //--- if(iTime[bar]>=IndTime[0] && iTime[bar+1]