//+------------------------------------------------------------------+ //| AnalysisOnBars.mq4 | //| PozitiF | //| mail: alex-w-@bk.ru | //+------------------------------------------------------------------+ #property copyright "PozitiF" #property link "mail: alex-w-@bk.ru" #property indicator_separate_window #property indicator_level1 0 #property indicator_buffers 4 #property indicator_color1 Red // Тело бара #property indicator_color2 Black // Тень #property indicator_color3 Black // Тень down #property indicator_width1 3 #property indicator_width2 1 #property indicator_width3 1 #property indicator_color4 Blue // Тело бара #property indicator_width4 3 //================ Настраиваемые параметры индикатора ================ extern string Symb =""; extern int LimitBars = 500; //================ Глобальные переменные индикатора ================== double Buffer1[]; double Buffer2[]; double Buffer3[]; double Buffer4[]; string IndName="AnalysisOnBars"; string sy; //================ Подключаемые библиотеки индикатора ================ //+------------------------------------------------------------------+ //| #############--- expert initialization function ---############# | //+------------------------------------------------------------------+ int init() { //---- SetIndexStyle(0, DRAW_HISTOGRAM); SetIndexBuffer(0, Buffer1); SetIndexStyle(1, DRAW_HISTOGRAM); SetIndexBuffer(1, Buffer2); SetIndexStyle(2, DRAW_HISTOGRAM); SetIndexBuffer(2, Buffer3); SetIndexStyle(3, DRAW_HISTOGRAM); SetIndexBuffer(3, Buffer4); if(Symb=="")sy=Symbol(); else sy=Symb; IndicatorShortName(IndName+": "+sy+" | "); //---- return(0); } //+------------------------------------------------------------------+ //| ###########--- expert deinitialization function ---############# | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| ##############--- expert start function ---#################### | //+------------------------------------------------------------------+ int start() { //----------------- Variable Initialization -------------------------+ int limit, counted_bars, spr, window; static int st_spr, spr_max, spr_min; double point, OpenBar, CloseBar, LowBar, HighBar; //---- point = MarketInfo(sy, MODE_POINT); spr = MarketInfo(sy,MODE_SPREAD); window = WindowFind(IndName+": "+sy+" | "); counted_bars=IndicatorCounted(); if(LimitBars > 0){ if(counted_bars>0) limit = LimitBars - 1; limit = LimitBars - limit; } else { if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; } for(int i=0; i spr_max){ spr_max=st_spr; Spread="Max: " + DoubleToStr(spr_max, 0); SetLabelText(sy+"_max", Spread, 10, 1, Blue, 1, "Times New Roman", 10, window); } if((st_spr!=spr_min && st_spr!=0 && st_spr < spr_min) || (spr_min==0)){ spr_min=st_spr; Spread="Min: " + DoubleToStr(spr_min, 0); SetLabelText(sy+"_min", Spread, 60, 1, Blue, 1, "Times New Roman", 10, window); } } //---- return(0); } //+------------------------------------------------------------------+ //| автор: Pozitif mail: alex-w-@bk.ru | //+------------------------------------------------------------------+ //| Создаёт текстовую метку | //+------------------------------------------------------------------+ //| параметры: | //| id - идентификатор метки (уникальное имя) | //| tx - текст метки | //| x - координата в пикселях, по горизонтали | //| y - координата в пикселях по вертикали | //| cl - цвет | //| bd - Binding, угол привязки объекта 0-3 | //| ft - шрифт | //| sz - размер шрифта | //| wd - номер окна в котором создавать метку | //| rt - вращение объекта в градусах | //+------------------------------------------------------------------+ void SetLabelText(string id, string tx="NULL", int x=0, int y=0, color cl=Black, int bd=0, string ft="Georgia", int sz=12, int wd=0, int rt=0){ //--- Если метка уже есть но не переданы координаты то удаляем --- if(tx!="NULL"){ if(ObjectFind(id)<0)ObjectCreate(id, OBJ_LABEL, wd, 0, 0); ObjectSetText(id, tx, sz, ft, cl); ObjectSet(id, OBJPROP_CORNER, bd); ObjectSet(id, OBJPROP_XDISTANCE, x); ObjectSet(id, OBJPROP_YDISTANCE, y); ObjectSet(id,OBJPROP_ANGLE,rt); }else{ if(tx=="NULL"&&ObjectFind(id)>=0)ObjectDelete(id); } } //+------------------------------------------------------------------+