//+------------------------------------------------------------------+ //| MultiColorCandles.mq4 | //| Copyright © 2010, Vladimir Hlystov | //| http://cmillion.narod.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2010, Vladimir Hlystov" #property link "http://cmillion.narod.ru" #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 White #property indicator_style1 0 #property indicator_width1 2 extern string тип_вывода ="0-свечи 1-бары 2-линия"; //+------------------------------------------------------------------+ extern int DrawCandle = 1; extern string simbol="";//"SIH0";//GCJ0";//"SILVER";//ЕСЛИ "" то текущий //+------------------------------------------------------------------+ datetime TekTime; double price[]; //+------------------------------------------------------------------+ int init() { IndicatorBuffers(1); SetIndexBuffer(0,price); SetIndexStyle (0,DRAW_LINE,STYLE_SOLID); TekTime=Time[0]; if (DrawCandle<3) { string name="0";ObjectCreate(name,OBJ_LABEL,0,0,0);ObjectSet(name, OBJPROP_CORNER, 3); ObjectSet(name, OBJPROP_XDISTANCE,5);ObjectSet(name, OBJPROP_YDISTANCE,120); ObjectSetText(name,"размер бар",8,"Times New Roman",Gray); for (int i=10; i<=100; i=i+10) { name=DoubleToStr(i,0);ObjectCreate(name,OBJ_LABEL,0,0,0);ObjectSet(name, OBJPROP_CORNER, 3); ObjectSet(name, OBJPROP_XDISTANCE,5);ObjectSet(name, OBJPROP_YDISTANCE,5+i); name=name+"M";ObjectCreate(name,OBJ_LABEL,0,0,0);ObjectSet(name, OBJPROP_CORNER, 3); ObjectSet(name, OBJPROP_XDISTANCE,30);ObjectSet(name, OBJPROP_YDISTANCE,5+i);} } if (simbol=="") simbol=Symbol(); SetIndexLabel(0,simbol); return(0); } //+------------------------------------------------------------------+ int deinit() { if (DrawCandle<3) del(simbol); for (int i=0; i<=100; i=i+10) {ObjectDelete(DoubleToStr(i,0)); ObjectDelete(DoubleToStr(i,0)+"M");} return(0); } //+------------------------------------------------------------------+ int start() { int BarsWind=WindowFirstVisibleBar(); double High_Win = High[iHighest(NULL,0,MODE_HIGH,BarsWind,0)]; double Low_Win = Low[iLowest(NULL,0,MODE_LOW,BarsWind,0)]; double H = iHigh(simbol,0,iHighest(simbol,0,MODE_HIGH,BarsWind,0)); double L = iLow(simbol,0,iLowest(simbol,0,MODE_LOW,BarsWind,0)); double OpenBar,CloseBar,LowBar,HighBar; string nameCandle; int Digit = MarketInfo(simbol,MODE_DIGITS); if (DrawCandle<3) del(simbol); if (true) { double maxCandl,Candl; for(int i=BarsWind; i>=0; i--) //находим максимальную свечу { Candl = (High[i]-Low[i])/Point; if (maxCandl=0; i--) { OpenBar = iOpen (simbol,0,i); CloseBar= iClose(simbol,0,i); LowBar = iLow (simbol,0,i); HighBar = iHigh (simbol,0,i); if (DrawCandle<3) { if (i==0) nameCandle=simbol; else nameCandle=StringConcatenate(simbol," ",TimeToStr(Time[i],TIME_MINUTES),"\n", "O ",DoubleToStr(OpenBar,Digit),"\n", "H ",DoubleToStr(HighBar,Digit),"\n", "L ",DoubleToStr(LowBar,Digit),"\n", "C ",DoubleToStr(CloseBar,Digit)); if (OpenBar>CloseBar) color1 = BLUE(((HighBar-LowBar)/Point)*100/maxCandl); else color1 = RED(((HighBar-LowBar)/Point)*100/maxCandl); } OpenBar =(OpenBar -L)/(H-L)*(High_Win-Low_Win)+Low_Win; CloseBar=(CloseBar-L)/(H-L)*(High_Win-Low_Win)+Low_Win; LowBar =(LowBar -L)/(H-L)*(High_Win-Low_Win)+Low_Win; HighBar =(HighBar -L)/(H-L)*(High_Win-Low_Win)+Low_Win; price[i] = (OpenBar+CloseBar+LowBar+HighBar)/4; if (DrawCandle==0) { ObjectCreate(nameCandle, OBJ_TREND, 0,Time[i],HighBar,Time[i],LowBar); ObjectSet (nameCandle, OBJPROP_COLOR, color1); ObjectSet (nameCandle, OBJPROP_STYLE, STYLE_SOLID); ObjectSet (nameCandle, OBJPROP_BACK, false); ObjectSet (nameCandle, OBJPROP_RAY, false); ObjectSet (nameCandle, OBJPROP_WIDTH, indicator_width1); nameCandle=StringConcatenate(nameCandle,"."); ObjectCreate(nameCandle, OBJ_TREND, 0,Time[i+1],OpenBar,Time[i],OpenBar); ObjectSet (nameCandle, OBJPROP_COLOR, color1); ObjectSet (nameCandle, OBJPROP_STYLE, STYLE_SOLID); ObjectSet (nameCandle, OBJPROP_BACK, false); ObjectSet (nameCandle, OBJPROP_RAY, false); ObjectSet (nameCandle, OBJPROP_WIDTH, indicator_width1); nameCandle=StringConcatenate(nameCandle,"_"); ObjectCreate(nameCandle, OBJ_TREND, 0,Time[i],CloseBar,Time[i]+Period()*60,CloseBar); ObjectSet (nameCandle, OBJPROP_COLOR, color1); ObjectSet (nameCandle, OBJPROP_STYLE, STYLE_SOLID); ObjectSet (nameCandle, OBJPROP_BACK, false); ObjectSet (nameCandle, OBJPROP_RAY, false); ObjectSet (nameCandle, OBJPROP_WIDTH, indicator_width1); } if (DrawCandle==1) { ObjectCreate(nameCandle, OBJ_TREND,0,Time[i],LowBar,Time[i],HighBar,0,0); ObjectSet (nameCandle, OBJPROP_WIDTH, 1); ObjectSet (nameCandle, OBJPROP_COLOR, color1); ObjectSet (nameCandle, OBJPROP_RAY, false); nameCandle=StringConcatenate(nameCandle," Body"); ObjectCreate(nameCandle, OBJ_TREND,0,Time[i],OpenBar,Time[i],CloseBar,0,0); ObjectSet (nameCandle, OBJPROP_WIDTH, 4); ObjectSet (nameCandle, OBJPROP_COLOR, color1); ObjectSet (nameCandle, OBJPROP_RAY, false); } if (DrawCandle==2) { ObjectCreate(nameCandle, OBJ_TREND,0,Time[i+1],price[i+1],Time[i],price[i],0,0); ObjectSet (nameCandle, OBJPROP_WIDTH, indicator_width1); ObjectSet (nameCandle, OBJPROP_COLOR, color1); ObjectSet (nameCandle, OBJPROP_RAY, false); } } return(0); } //+------------------------------------------------------------------+ color BLUE(int i) { int BB=i*2.55; return((BB<<16)^(0<<8)^(50)); } //+------------------------------------------------------------------+ color RED(int i) { int RR=i*2.55; return((50<<16)^(0<<8)^(RR)); } //+------------------------------------------------------------------+ int del(string tekst) { for(int n=ObjectsTotal()-1; n>=0; n--) { string Obj_Name=ObjectName(n); if (StringFind(Obj_Name,tekst,0) != -1) { ObjectDelete(Obj_Name); } } return; } //+------------------------------------------------------------------+