//+------------------------------------------------------------------+ //| FiboRetracement.mq4 | //| Copyright © 2005, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_chart_window #property indicator_buffers 7 #property indicator_color1 Black #property indicator_color2 Black //Blue #property indicator_color3 Black #property indicator_color4 Black //Blue #property indicator_color5 Black #property indicator_color6 Black //Blue #property indicator_color7 Black #property indicator_color8 Black //Blue //---- input parameters extern int nLeft = 50; extern int nRight = 50; extern int filter = 10; extern int diff=15; extern double lots=0.1; extern color level1=Black; extern color level2=Black; //---- buffers double UpBuffer[]; double DnBuffer[]; double f_2[]; double f_3[]; double f_4[]; double f_5[]; double f_6[]; //---- int draw_begin1 = 0, draw_begin2 = 0, d_b3 = 0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { double nfUp; //---- indicators SetIndexStyle(0, DRAW_LINE, 0, 2); SetIndexStyle(1, DRAW_LINE, 0, 2); SetIndexStyle(2, DRAW_LINE, 2); SetIndexStyle(3, DRAW_LINE, 2); SetIndexStyle(4, DRAW_LINE, 2); SetIndexStyle(5, DRAW_LINE, 2); SetIndexStyle(6, DRAW_LINE, 2); SetIndexBuffer(0, UpBuffer); SetIndexBuffer(1, DnBuffer); SetIndexBuffer(2, f_2); SetIndexBuffer(3, f_3); SetIndexBuffer(4, f_4); SetIndexBuffer(5, f_5); SetIndexBuffer(6, f_6); //---- name for DataWindow and indicator subwindow label string short_name; //обявление переменной short_name типа "строковый" //переменной short_name присваиваем строковое значение равное выражению short_name = "rvmFractalsLevel(" + nLeft + "," + nRight + "," + filter + ")"; IndicatorShortName(short_name); //для отображения на графике присвоим индикатору краткое //наименование //для отображения на графике присвоим метке отображающей значения 0 буфера имя Up Channel SetIndexLabel(0, "Up Level (" + nLeft + "," + nRight + "," + filter + ")"); //для отображения на графике присвоим метке отображающей значения 1 буфера имя Down Channel SetIndexLabel(1, "Down Level (" + nLeft + "," + nRight + "," + filter + ")"); SetIndexLabel(2, "f_2 (" + nLeft + "," + nRight + "," + filter + ")"); SetIndexLabel(3, "f_3 (" + nLeft + "," + nRight + "," + filter + ")"); SetIndexLabel(4, "f_4 (" + nLeft + "," + nRight + "," + filter + ")"); SetIndexLabel(5, "f_5 (" + nLeft + "," + nRight + "," + filter + ")"); SetIndexLabel(6, "f_6 (" + nLeft + "," + nRight + "," + filter + ")"); //---- Здесь определим начальные точки для прорисовки индикатора int n, k, i, Range = nLeft + nRight + 1; //переберем свечки от (всего свечек минус минимум свечек слева) до (минимум свечек справа) for(n = Bars - 1 - nLeft; n >= nRight; n--) { //верхние фракталы //если начало отрисовки верхнего уровня не определено if(draw_begin1 == 0) { //текущая свеча максимум на локальном промежутке? if(High[n] >= High[Highest(NULL, 0, MODE_HIGH, Range, n - nRight)]) { int fRange = nvnLeft(n, nLeft) + nvnRight(n, nRight) + 1; //если она же - фрактал if(High[n] >= High[Highest(NULL, 0, MODE_HIGH, fRange, n - nvnRight(n, nRight))]) { draw_begin1 = Bars - n; //начало отрисовки верхнего уровня определено for(i = Bars - 1; i > draw_begin1; i--) { UpBuffer[i] = High[Bars - draw_begin1]; } } }//конец действий если if(High[n]>=High[Highest(NULL,0,MODE_HIGH,Range,n-nRight)]=истина }//конец условия if(draw_begin1==0) //нижние фракталы //если начало отрисовки нижнего уровня не определено if(draw_begin2 == 0) { //текущая свеча минимум на локальном промежутке? if(Low[n] <= Low[Lowest(NULL, 0, MODE_LOW, Range, n - nRight)]) { fRange = nvnLeft(n, nLeft) + nvnRight(n, nRight) + 1; //если она же - фрактал if(Low[n] <= Low[Lowest(NULL, 0, MODE_HIGH, fRange, n - nvnRight(n, nRight))]) { draw_begin2 = Bars - n; //начало отрисовки нижнего уровня определено for(i = Bars - 1; i > draw_begin2; i--) { DnBuffer[i] = Low[Bars - draw_begin2]; } } }//конец условия if(Low[n]<=Low[Lowest(NULL,0,MODE_LOW,Range,n-nRight)])=true }//конец условия if(draw_begin2==0) //если оба начала отрисовки уровней определены, выходим из цикла for(n=Bars-1-nLeft;n>=nRight;n--) if(draw_begin1 > 0 && draw_begin2 > 0) break; }//конец цикла for(n=Bars-1-nLeft;n>=nRight;n--) //---- if(draw_begin1 > draw_begin2) { d_b3 = draw_begin1; } else { d_b3 = draw_begin2; } SetIndexDrawBegin(0, draw_begin1); //установка начальной точки прорисовки для 0 буфера SetIndexDrawBegin(1, draw_begin2); //установка начальной точки прорисовки для 1 буфера SetIndexDrawBegin(2, d_b3); SetIndexDrawBegin(3, d_b3); SetIndexDrawBegin(4, d_b3); SetIndexDrawBegin(5, d_b3); SetIndexDrawBegin(6, d_b3); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int nLeft1 = 50; static int bar1=0; if(Bars!=bar1) { nLeft1=25; bar1=Bars; } double nleft2=nLeft1; string Market_Price; if(nLeft1==50){Market_Price="THIRUs LEVEL";} ObjectCreate("Market_Price_Label", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label", Market_Price, 24, "Comic Sans MS", LawnGreen); ObjectSet("Market_Price_Label", OBJPROP_CORNER, 2); ObjectSet("Market_Price_Label", OBJPROP_XDISTANCE, 50); ObjectSet("Market_Price_Label", OBJPROP_YDISTANCE, 3); double UpStage = 0.0, DnStage = 0.0; int i, j, fRange, Range = nLeft1 + nRight + 1; int counted_bars = IndicatorCounted(); //---- //перебираем свечки от (Bars-counted_bars-nLeft) до (nRight) включительно for(i = Bars - 1 - counted_bars - nLeft1; i >= nRight; i--) { //если свеча локальный максимум if(High[i] >= High[Highest(NULL, 0, MODE_HIGH, Range, i - nRight)]) { //Print(TimeToStr(Time[i]), "******Локальный максимум"); fRange = nvnLeft(i, nLeft1) + nvnRight(i, nRight) + 1; //если она же - фрактал if(High[i] >= High[Highest(NULL, 0, MODE_HIGH, fRange, i - nvnRight(i, nRight))]) { UpStage = High[i]; //Print(" она же фрактал"); } else { if(High[i] <= UpBuffer[i+1]) { UpStage = UpBuffer[i+1]; //Print(" не фрактал, но ниже предыдущего уровня"); } else { UpStage = nfUp(i); //Print(" не фрактал, выше предыдущего уровня"); } } } else { //Print(TimeToStr(Time[i]), "******не локальный максимум"); if(High[i] <= UpBuffer[i+1]) { UpStage = UpBuffer[i+1]; //Print(" ниже предыдущего уровня"); } else { UpStage = nfUp(i); //Print(" выше предыдущего уровня"); } } //если свеча локальный минимум if(Low[i] <= Low[Lowest(NULL, 0, MODE_LOW, Range, i - nRight)]) { fRange = nvnLeft(i, nLeft1) + nvnRight(i, nRight) + 1; //Print(TimeToStr(Time[i])," ",nvnLeft(i,nLeft)," ",nvnRight(i,nRight)+1); //если она же - фрактал if(Low[i] <= Low[Lowest(NULL, 0, MODE_HIGH, fRange, i - nvnRight(i, nRight))]) { DnStage = Low[i]; } else { if(Low[i] >= DnBuffer[i+1]) { DnStage = DnBuffer[i+1]; } else { DnStage = nfDn(i); } } } else { if(Low[i] >= DnBuffer[i+1]) { DnStage = DnBuffer[i+1]; } else { DnStage = nfDn(i); } } UpBuffer[i] = UpStage; DnBuffer[i] = DnStage; //---- расчет остальных буферов f_2[i] = NormalizeDouble(DnBuffer[i] + (UpBuffer[i] - DnBuffer[i]) / 6, 4); f_3[i] = NormalizeDouble(DnBuffer[i] + (UpBuffer[i] - DnBuffer[i]) / 3, 4); f_4[i] = NormalizeDouble(DnBuffer[i] + (UpBuffer[i] - DnBuffer[i]) / 2, 4); f_5[i] = NormalizeDouble(DnBuffer[i] + (UpBuffer[i] - DnBuffer[i])*2 / 3, 4); f_6[i] = NormalizeDouble(DnBuffer[i] + (UpBuffer[i] - DnBuffer[i])*5 / 6, 4); }//конец цикла for(i=Bars-counted_bars-nLeft;i>=nRight;i--) for(i = nRight - 1; i >= 0; i--) { if(High[i] <= UpBuffer[i+1]) { UpStage = UpBuffer[i+1]; } else { UpStage = nfUp(i); } //---- if(Low[i] >= DnBuffer[i+1]) { DnStage = DnBuffer[i+1]; } else { DnStage = nfDn(i); } UpBuffer[i] = UpStage; DnBuffer[i] = DnStage; //---- расчет остальных буферов f_2[i] = NormalizeDouble(DnBuffer[i] + (UpBuffer[i] - DnBuffer[i]) / 6, 4); f_3[i] = NormalizeDouble(DnBuffer[i] + (UpBuffer[i] - DnBuffer[i]) / 3, 4); f_4[i] = NormalizeDouble(DnBuffer[i] + (UpBuffer[i] - DnBuffer[i]) / 2, 4); f_5[i] = NormalizeDouble(DnBuffer[i] + (UpBuffer[i] - DnBuffer[i])*2 / 3, 4); f_6[i] = NormalizeDouble(DnBuffer[i] + (UpBuffer[i] - DnBuffer[i])*5 / 6, 4); } //---- построение веера Фибоначчи double LastUp, LastDn, st_h, st_l, st_3, y1, y2, y3; int tmp, x1=0, x2=0, x3=0, cb, dn_x, up_x; string fibo = "Fibo 1", fibo2 = "Fibo 2"; LastDn = DnBuffer[0]; for(cb = 1; cb <= Bars - 1; cb++) { if(tmp != 1 && LastDn > DnBuffer[cb]) { tmp = 1; continue; } if(tmp == 1 && DnBuffer[cb] > DnBuffer[cb-1]) { tmp = 0; dn_x = cb - 1; break; } } LastUp = UpBuffer[0]; for(cb = 1; cb <= Bars - 1; cb++) { if(tmp != 1 && LastUp < UpBuffer[cb]) { tmp = 1; continue; } if(tmp == 1 && UpBuffer[cb] < UpBuffer[cb-1]) { tmp = 0; up_x = cb - 1; break; } } st_h = High[Highest(NULL, 0, MODE_HIGH, MathMax(dn_x, up_x),0)]; st_l = Low[Lowest(NULL, 0, MODE_LOW, MathMax(dn_x, up_x), 0)]; //y1=MathMin(Open[x1],Close[x1]); //y1=MathMax(Open[x1],Close[x1]); for(cb = MathMax(dn_x, up_x) - 1; cb >= 0; cb--) { if(High[cb] == st_h || Low[cb] == st_l) { if(High[cb] == st_h && (x1 == 0 || x2 == 0)) { if(x1 == 0) { x1 = cb; y1 = High[x1]; continue; } else { x2 = cb; y2 = High[x2]; break; } } else { if(x1 == 0) { x1 = cb; y1 = Low[x1]; continue; } else { x2 = cb; y2 = Low[x2]; break; } } } } //Print("x1="+x1+" y1="+y1+" x2="+x2+" y2="+y2); if(ObjectFind(fibo) != -1 ) { ObjectSet(fibo, OBJPROP_TIME1, Time[x1]); ObjectSet(fibo, OBJPROP_PRICE1, y1); ObjectSet(fibo, OBJPROP_TIME2, Time[x2]); ObjectSet(fibo, OBJPROP_PRICE2, y2); } else { ObjectCreate(fibo, OBJ_FIBO,0, Time[x1], y1, Time[x2], y2); ObjectSet(fibo, OBJPROP_COLOR, DodgerBlue); ObjectSet(fibo, OBJPROP_LEVELCOLOR, Blue); ObjectSet(fibo, OBJPROP_STYLE, STYLE_DOT); // ObjectSet(fibo, OBJPROP_LEVELSTYLE, STYLE_DASHDOT); ObjectSet(fibo,OBJPROP_FIBOLEVELS,12); Print("Количество индексов Fibo1=",ObjectGet(fibo,OBJPROP_FIBOLEVELS)); Print("Ошибка количества индексов Fibo1=",GetLastError()); if(!ObjectSet(fibo,OBJPROP_FIRSTLEVEL+0,0.0)) Print("Ошибка установки уровня 1 Fibo1 ",GetLastError()); if(!ObjectSet(fibo,OBJPROP_FIRSTLEVEL+1,0.207)) Print("Ошибка установки уровня 1 Fibo1 ",GetLastError()); if(!ObjectSet(fibo,OBJPROP_FIRSTLEVEL+2,0.236)) Print("Ошибка установки уровня 1 Fibo1 ",GetLastError()); if(!ObjectSet(fibo,OBJPROP_FIRSTLEVEL+3,0.265)) Print("Ошибка установки уровня 1 Fibo1 ",GetLastError()); if(!ObjectSet(fibo,OBJPROP_FIRSTLEVEL+4,0.382)) Print("Ошибка установки уровня 1 Fibo1 ",GetLastError()); if(!ObjectSet(fibo,OBJPROP_FIRSTLEVEL+5,0.50)) Print("Ошибка установки уровня 2 Fibo1 ",GetLastError()); if(!ObjectSet(fibo,OBJPROP_FIRSTLEVEL+6,0.618)) Print("Ошибка установки уровня 3 Fibo1 ",GetLastError()); if(!ObjectSet(fibo,OBJPROP_FIRSTLEVEL+7,0.735)) Print("Ошибка установки уровня 1 Fibo1 ",GetLastError()); if(!ObjectSet(fibo,OBJPROP_FIRSTLEVEL+8,0.764)) Print("Ошибка установки уровня 4 Fibo1 ",GetLastError()); if(!ObjectSet(fibo,OBJPROP_FIRSTLEVEL+9,0.793)) Print("Ошибка установки уровня 1 Fibo1 ",GetLastError()); if(!ObjectSet(fibo,OBJPROP_FIRSTLEVEL+10,1.00)) Print("Ошибка установки уровня 1 Fibo1 ",GetLastError()); //if(!ObjectSet(fibo,OBJPROP_FIRSTLEVEL+11,0.854)) Print("Ошибка установки уровня 4 Fibo1 ",GetLastError()); ObjectSetFiboDescription( fibo, 0,"0.0"); ObjectSetFiboDescription( fibo, 1,"20.7"); ObjectSetFiboDescription( fibo, 2,"23.6"); ObjectSetFiboDescription( fibo, 3,"26.5"); ObjectSetFiboDescription( fibo, 4,"38.2"); ObjectSetFiboDescription( fibo, 5,"50.0"); ObjectSetFiboDescription( fibo, 6,"61.8"); ObjectSetFiboDescription( fibo, 7,"73.5"); ObjectSetFiboDescription( fibo, 8,"76.4"); ObjectSetFiboDescription( fibo, 9,"79.3"); ObjectSetFiboDescription( fibo, 10,"100"); // ObjectSetFiboDescription( fibo, 11,"85.4"); } //----- а это отрисовка вспомогательного веера фибоначчи if(y2 > y1) { st_3 = Low[Lowest(NULL, 0, MODE_LOW, x2, 0)]; } else { st_3 = High[Highest(NULL, 0, MODE_HIGH, x2, 0)]; } //---- for(cb = 0; cb < x2; cb++) { if(y2 > y1 && Low[cb] == st_3) { x3 = cb; y3 = Low[cb]; break; } else { if(y2 < y1 && High[cb] == st_3) { x3 = cb; y3 = High[cb]; break; } } } double thiru1=0,thiru2=0,thiru3=0,thiru4=0,thiru5=0,corner=4; static double order1=0,order2=0,t207=0,t265=0,t735=0,t793=0,hl=0; color FontColor1=Blue, FontColor2=Red; int line1=25,line2=50,line3=75,line4=100,space1=10,space2=150,FontSize1=12,FontSize2=12; static int level265=0,level793=0; string Market_Price1,Market_Price2,Market_Price3,Market_Price4,Market_Price5,FontType1="Times New Roman",FontType2="Comic Sans MS"; if(nLeft1==50) { if(y3>=y2+10*Point) { if(order1 != y2 || order2 != y3) // variable intitlization function { order1=y2; order2=y3; hl=y3-y2; t207=y3-(hl*0.207); t265=y3-(hl*0.265); t735=y3-(hl*0.735); t793=y3-(hl*0.793); level265=0; level793=0; } if(level265==0) { if((t207-t265)>=diff*Point) { if(Bid==t265) { OrderSend(Symbol(),OP_BUY,lots,Bid,3,0,t207,"BUY OPENED",0,0,Green); }}} thiru1=(y3-((y3-y2)*0.265)); thiru2=(y3-((y3-y2)*0.207)); thiru3=(y3-((y3-y2)*0.793)); thiru4=(y3-((y3-y2)*0.735)); Market_Price1=DoubleToStr(thiru1, Digits); Market_Price2=DoubleToStr(thiru2, Digits); Market_Price3=DoubleToStr(thiru3, Digits); Market_Price4=DoubleToStr(thiru4, Digits); ObjectCreate("Market_Price_Label2", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label2","Buy @ 236 Level : " ,FontSize1, FontType1, FontColor1); ObjectSet("Market_Price_Label2", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label2", OBJPROP_XDISTANCE, space1); ObjectSet("Market_Price_Label2", OBJPROP_YDISTANCE, line1); ObjectCreate("Market_Price_Label9", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label9",Market_Price1, FontSize2,FontType2 , FontColor2); ObjectSet("Market_Price_Label9", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label9", OBJPROP_XDISTANCE, space2); ObjectSet("Market_Price_Label9", OBJPROP_YDISTANCE, line1); ObjectCreate("Market_Price_Label3", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label3","Close @ 236 Level : " ,FontSize1, FontType1, FontColor1); ObjectSet("Market_Price_Label3", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label3", OBJPROP_XDISTANCE, space1); ObjectSet("Market_Price_Label3", OBJPROP_YDISTANCE, line2); ObjectCreate("Market_Price_Label4", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label4",Market_Price2, FontSize2,FontType2 , FontColor2); ObjectSet("Market_Price_Label4", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label4", OBJPROP_XDISTANCE, space2); ObjectSet("Market_Price_Label4", OBJPROP_YDISTANCE, line2); ObjectCreate("Market_Price_Label5", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label5","Buy @ 764 Level : " ,FontSize1, FontType1, FontColor1); ObjectSet("Market_Price_Label5", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label5", OBJPROP_XDISTANCE, space1); ObjectSet("Market_Price_Label5", OBJPROP_YDISTANCE, line3); ObjectCreate("Market_Price_Label6", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label6",Market_Price3, FontSize2,FontType2 , FontColor2); ObjectSet("Market_Price_Label6", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label6", OBJPROP_XDISTANCE, space2); ObjectSet("Market_Price_Label6", OBJPROP_YDISTANCE, line3); ObjectCreate("Market_Price_Label7", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label7","Close @ 764 Level : " ,FontSize1, FontType1, FontColor1); ObjectSet("Market_Price_Label7", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label7", OBJPROP_XDISTANCE, space1); ObjectSet("Market_Price_Label7", OBJPROP_YDISTANCE, line4); ObjectCreate("Market_Price_Label8", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label8",Market_Price4, FontSize2,FontType2 , FontColor2); ObjectSet("Market_Price_Label8", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label8", OBJPROP_XDISTANCE, space2); ObjectSet("Market_Price_Label8", OBJPROP_YDISTANCE, line4); thiru5=(thiru2-thiru1)*10000; thiru5=NormalizeDouble(thiru5,0); Market_Price5=DoubleToStr(thiru5, Digits); ObjectCreate("Market_Price_Label10", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label10",Market_Price5 ,24, FontType1, Violet); ObjectSet("Market_Price_Label10", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label10", OBJPROP_XDISTANCE, 250); ObjectSet("Market_Price_Label10", OBJPROP_YDISTANCE, 58); } else { thiru1=y2-((y2-y3)*0.735); thiru2=y2-((y2-y3)*0.793); thiru3=y2-((y2-y3)*0.207); thiru4=y2-((y2-y3)*0.265); Market_Price1=DoubleToStr(thiru1, Digits); Market_Price2=DoubleToStr(thiru2, Digits); Market_Price3=DoubleToStr(thiru3, Digits); Market_Price4=DoubleToStr(thiru4, Digits); ObjectCreate("Market_Price_Label2", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label2","Sell @ 764 Level : " ,FontSize1, FontType1, FontColor1); ObjectSet("Market_Price_Label2", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label2", OBJPROP_XDISTANCE, space1); ObjectSet("Market_Price_Label2", OBJPROP_YDISTANCE, line1); ObjectCreate("Market_Price_Label9", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label9",Market_Price1, FontSize2,FontType2 , FontColor2); ObjectSet("Market_Price_Label9", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label9", OBJPROP_XDISTANCE, space2); ObjectSet("Market_Price_Label9", OBJPROP_YDISTANCE, line1); ObjectCreate("Market_Price_Label3", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label3","Close @ 764 Level : " ,FontSize1, FontType1, FontColor1); ObjectSet("Market_Price_Label3", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label3", OBJPROP_XDISTANCE, space1); ObjectSet("Market_Price_Label3", OBJPROP_YDISTANCE, line2); ObjectCreate("Market_Price_Label4", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label4",Market_Price2, FontSize2,FontType2 , FontColor2); ObjectSet("Market_Price_Label4", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label4", OBJPROP_XDISTANCE, space2); ObjectSet("Market_Price_Label4", OBJPROP_YDISTANCE, line2); ObjectCreate("Market_Price_Label5", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label5","Sell @ 236 Level : " ,FontSize1, FontType1, FontColor1); ObjectSet("Market_Price_Label5", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label5", OBJPROP_XDISTANCE, space1); ObjectSet("Market_Price_Label5", OBJPROP_YDISTANCE, line3); ObjectCreate("Market_Price_Label6", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label6",Market_Price3, FontSize2,FontType2 , FontColor2); ObjectSet("Market_Price_Label6", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label6", OBJPROP_XDISTANCE, space2); ObjectSet("Market_Price_Label6", OBJPROP_YDISTANCE, line3); ObjectCreate("Market_Price_Label7", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label7","Close @ 236 Level : " ,FontSize1, FontType1, FontColor1); ObjectSet("Market_Price_Label7", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label7", OBJPROP_XDISTANCE, space1); ObjectSet("Market_Price_Label7", OBJPROP_YDISTANCE, line4); ObjectCreate("Market_Price_Label8", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label8",Market_Price4, FontSize2,FontType2 , FontColor2); ObjectSet("Market_Price_Label8", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label8", OBJPROP_XDISTANCE, space2); ObjectSet("Market_Price_Label8", OBJPROP_YDISTANCE, line4); thiru5=(thiru1-thiru2)*10000; thiru5=NormalizeDouble(thiru5,0); Market_Price5=DoubleToStr(thiru5, Digits); ObjectCreate("Market_Price_Label10", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label10",Market_Price5 ,24, FontType1, Violet); ObjectSet("Market_Price_Label10", OBJPROP_CORNER, corner); ObjectSet("Market_Price_Label10", OBJPROP_XDISTANCE, 250); ObjectSet("Market_Price_Label10", OBJPROP_YDISTANCE, 58); } } string Market_Price6=0; double thiru6=0; if(y1>=y2+10*Point){thiru6=((y1-(y1-y2)*0.207)-(y1-(y1-y2)*0.264))*10000;}else {thiru6=((y2-(y2-y1)*0.207)-(y2-(y2-y1)*0.264))*10000;} thiru6=NormalizeDouble(thiru6,0); Market_Price6=DoubleToStr(thiru6, Digits); ObjectCreate("Market_Price_Label11", OBJ_LABEL, 0, 0, 0); ObjectSetText("Market_Price_Label11",Market_Price6 ,24, "Times New Roman", Blue); ObjectSet("Market_Price_Label11", OBJPROP_CORNER, 4); ObjectSet("Market_Price_Label11", OBJPROP_XDISTANCE, 450); ObjectSet("Market_Price_Label11", OBJPROP_YDISTANCE, 58); if(ObjectFind(fibo2) != -1 ) { ObjectSet(fibo2, OBJPROP_TIME1, Time[x2]); ObjectSet(fibo2, OBJPROP_PRICE1, y2); ObjectSet(fibo2, OBJPROP_TIME2, Time[x3]); ObjectSet(fibo2, OBJPROP_PRICE2, y3); } else { ObjectCreate(fibo2, OBJ_FIBO, 0, Time[x2], y2, Time[x3], y3); ObjectSet(fibo2, OBJPROP_COLOR, Yellow); ObjectSet(fibo2, OBJPROP_LEVELCOLOR, Violet); ObjectSet(fibo2, OBJPROP_STYLE, STYLE_DOT); ObjectSet(fibo2, OBJPROP_LEVELSTYLE, STYLE_DOT); ObjectSet(fibo2,OBJPROP_FIBOLEVELS,12); Print("Количество индексов Fibo1=",ObjectGet(fibo,OBJPROP_FIBOLEVELS)); Print("Ошибка количества индексов Fibo1=",GetLastError()); if(!ObjectSet(fibo2,OBJPROP_FIRSTLEVEL+0,0.0)) Print("Ошибка установки уровня 1 Fibo1 ",GetLastError()); if(!ObjectSet(fibo2,OBJPROP_FIRSTLEVEL+1,0.207)) Print("Ошибка установки уровня 1 Fibo1 ",GetLastError()); if(!ObjectSet(fibo2,OBJPROP_FIRSTLEVEL+2,0.236)) Print("Ошибка установки уровня 1 Fibo1 ",GetLastError()); if(!ObjectSet(fibo2,OBJPROP_FIRSTLEVEL+3,0.265)) Print("Ошибка установки уровня 1 Fibo1 ",GetLastError()); if(!ObjectSet(fibo2,OBJPROP_FIRSTLEVEL+4,0.382)) Print("Ошибка установки уровня 1 Fibo1 ",GetLastError()); if(!ObjectSet(fibo2,OBJPROP_FIRSTLEVEL+5,0.50)) Print("Ошибка установки уровня 2 Fibo1 ",GetLastError()); if(!ObjectSet(fibo2,OBJPROP_FIRSTLEVEL+6,0.618)) Print("Ошибка установки уровня 3 Fibo1 ",GetLastError()); if(!ObjectSet(fibo2,OBJPROP_FIRSTLEVEL+7,0.735)) Print("Ошибка установки уровня 1 Fibo1 ",GetLastError()); if(!ObjectSet(fibo2,OBJPROP_FIRSTLEVEL+8,0.764)) Print("Ошибка установки уровня 4 Fibo1 ",GetLastError()); if(!ObjectSet(fibo2,OBJPROP_FIRSTLEVEL+9,0.793)) Print("Ошибка установки уровня 1 Fibo1 ",GetLastError()); if(!ObjectSet(fibo2,OBJPROP_FIRSTLEVEL+10,1.00)) Print("Ошибка установки уровня 1 Fibo1 ",GetLastError()); //if(!ObjectSet(fibo2,OBJPROP_FIRSTLEVEL+11,0.854)) Print("Ошибка установки уровня 4 Fibo1 ",GetLastError()); ObjectSetFiboDescription( fibo2, 0,"0.0"); ObjectSetFiboDescription( fibo2, 1,"20.7"); ObjectSetFiboDescription( fibo2, 2,"23.6"); ObjectSetFiboDescription( fibo2, 3,"26.5"); ObjectSetFiboDescription( fibo2, 4,"38.2"); ObjectSetFiboDescription( fibo2, 5,"50.0"); ObjectSetFiboDescription( fibo2, 6,"61.8"); ObjectSetFiboDescription( fibo2, 7,"73.5"); ObjectSetFiboDescription( fibo2, 8,"76.4"); ObjectSetFiboDescription( fibo2, 9,"79.3"); ObjectSetFiboDescription( fibo2, 10,"100"); // ObjectSetFiboDescription( fibo2, 11,"85.4"); } if(nLeft1==25) { nLeft1=50; } //---- return(0); } //+------------------------------------------------------------------+ //| Функция nfUp возвращает ближайшее слева к переданной свече | //| значение буфера индикатора, большее или равное значению | //| High(Close) для переданной свечи. | //+------------------------------------------------------------------+ double nfUp(int i) { int l, flag = 0; double Price = 0.0; //---------- for(l = i + 1; l < Bars - draw_begin1 - 1; l++) { if(filter > 0) { if(Close[i] <= UpBuffer[l] + (UpBuffer[l] - DnBuffer[l])*filter / 100) { Price = UpBuffer[l]; flag = 1; //Print(TimeToStr(Time[i])," ",l," ",Bars," ",Price," ",UpBuffer[l]); } } else { if(High[i] <= UpBuffer[l]) { Price = UpBuffer[l]; flag = 1; } } //---- if(Price > 0) break; } if(flag == 0) Price = High[i]; //---------- return(Price); } //+------------------------------------------------------------------+ //| Функция nfDn возвращает ближайшее слева к переданной свече | //| значение буфера индикатора, меньшее или равное значению | //| Low(Close) для переданной свечи. | //+------------------------------------------------------------------+ double nfDn(int i) { int l, flag = 0; double Price = 0.0; //---------- for(l = i + 1; l < Bars - draw_begin2 - 1; l++) { if(filter > 0) { if(Close[i] >= DnBuffer[l] - (UpBuffer[l] - DnBuffer[l])*filter / 100) { Price = DnBuffer[l]; flag = 1; } } else { if(Low[i] >= DnBuffer[l]) { Price = DnBuffer[l]; flag = 1; } } //---- if(Price > 0) break; } if(flag == 0) Price = Low[i]; //---------- return(Price); } //+------------------------------------------------------------------+ //| Функция nvnLeft возвращает для переданной ей свечи минимальное | //| количество свечей слева, включая "внутренние", для того, чтобы | //| число не внутренних свечей в полученном диапазоне было не меньше,| //| чем указано во втором параметре. | //+------------------------------------------------------------------+ int nvnLeft(int i, int n) { int k = 0, l; for(l = i + 1; l <= Bars - 1; l++) { if(High[l] < High[l+1] && Low[l] > Low[l+1]) continue; k++; if(k == n) { k = l - i; break; } } //---------- return(k); } //+------------------------------------------------------------------+ //| Функция nvnRight возвращает для переданной ей свечи минимальное | //| количество свечей справа, включая "внутренние", для того, чтобы | //| число не внутренних свечей в полученном диапазоне было не меньше,| //| чем указано во втором параметре. | | //+------------------------------------------------------------------+ int nvnRight(int i, int n) { int k = 0, l; for(l = i - 1; l >= 0; l--) { if(High[l] < High[l+1] && Low[l] > Low[l+1]) continue; k++; if(k == n) { k = i - l; break; } } //---------- return(k); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { string fibo = "Fibo 1", fibo2 = "Fibo 2"; ObjectDelete(fibo); ObjectDelete(fibo2); //---- return(0); }