//+------------------------------------------------------------------+ //| MTF_Cycle_Point_KROUFR_version.mq4 | //+------------------------------------------------------------------+ #property copyright "Copyright © 2008 | Grayman77, zIG, akadex" #property link "ForexResearch" #property indicator_chart_window #property indicator_buffers 4 #property indicator_color1 Pink // Blue #property indicator_color2 Aqua // Red #property indicator_color3 Pink // SteelBlue #property indicator_color4 Aqua // IndianRed #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 3 #property indicator_width4 3 #property indicator_level1 80 #property indicator_level2 20 #property indicator_level3 50 //---- Внешние параметры extern double hZone=50; extern double lZone=50; extern int Period1=60; extern int Period3=240; extern int BarsCross=0; extern int PriceHL=0; // 0 - min/max-hi/lo //расчет минимумов/максимумов по хаям/лоу // 1 - min/max c/open (depending which is lower //расчет минимумов/максимумов по клозам/опенам (в зависимости что ниже) extern int PointTotal=3; // points 4 search amount //Количество точек для поиска extern bool Comments1=false; //---- extern int FastMA=12; extern int SlowMA=24; extern int Crosses=50; extern bool Comments=true; extern bool SoundON=true; //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double h[],l[]; //---- var int ShiftH[],ShiftL[]; double PriceH[], PriceL[],atr; double zD1h[],zD1l[],zD1ShiftH[],zD1ShiftL[],zD1PriceH[],zD1PriceL[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(7); SetIndexStyle(0,DRAW_ARROW); SetIndexBuffer(0,h); SetIndexArrow(0,242); //110 SetIndexStyle(1,DRAW_ARROW); SetIndexBuffer(1,l); SetIndexArrow(1,241); //110 SetIndexStyle(2,DRAW_ARROW); SetIndexBuffer(2,zD1h); SetIndexArrow(2,168);//110, then 168 SetIndexStyle(3,DRAW_ARROW); SetIndexBuffer(3,zD1l); SetIndexArrow(3,168);//110, then 168 SetIndexBuffer(4,ExtMapBuffer1); SetIndexBuffer(5,ExtMapBuffer2); SetIndexBuffer(6,ExtMapBuffer3); // Задать размерность массивов ArrayResize(ShiftH,PointTotal); ArrayResize(ShiftL,PointTotal); ArrayResize(PriceH,PointTotal); ArrayResize(PriceL,PointTotal); ArrayResize(zD1ShiftH,PointTotal); ArrayResize(zD1ShiftL,PointTotal); ArrayResize(zD1PriceH,PointTotal); ArrayResize(zD1PriceL,PointTotal); SetIndexEmptyValue(0,0.0); SetIndexEmptyValue(1,0.0); SetIndexEmptyValue(2,0.0); SetIndexEmptyValue(3,0.0); SetIndexLabel(0,"H"); SetIndexLabel(1,"L"); SetIndexLabel(2,"zD1H"); SetIndexLabel(3,"zD1L"); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //ObjectsDeleteAll(); Comment(""); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); int i,limit; double vtmp1,vtmp2; int finalSignal=0; int zTrendH4=0; // переменные для отслеживания состояния тренда по Н4 и Н1 int zTrendD1=0; // int zPhaseCnt=1; int zH4PhaseCnt=1; int zLastH4Bar=0; int zContTrend=0; int j; int hvar=0; int lvar=0; int hClose,hOpen,lClose,lOpen; double top, bottom, arrow_location; top = WindowPriceMax(0); bottom = WindowPriceMin(0); arrow_location = (top + bottom) / 2.0; //---- проверка на возможные ошибки if(counted_bars<0) return(-1); //---- последний посчитанный бар будет пересчитан if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; if(limit>Bars-2) limit=Bars-2; //---- for(i=limit;i>0;i--) { datetime _TimeBar=Time[i]; // current bar shift on 2 higher shiсмещение текущей свечи ТФ на 2 старше int Shift=iBarShift(Symbol(),Period1,_TimeBar,false); int Shift3=iBarShift(Symbol(),Period3,_TimeBar,false)+1; double v1=iCustom(Symbol(),Period1,"Cycle_KROUFR_version_",FastMA,SlowMA,Crosses,Comments,0,Shift); double v3=iCustom(Symbol(),Period3,"Cycle_KROUFR_version_",FastMA,SlowMA,Crosses,Comments,0,Shift3); ExtMapBuffer1[i]=v1; ExtMapBuffer3[i]=v3; } for(i=limit;i>0;i--) { //for current TF ДЛЯ ТЕКУЩЕГО ТФ // if on 2 last bars crooked line crosses hZone level down Если на двух последних барах кривая пересекает уровень hZone сверху вниз if(ExtMapBuffer1[i]hZone) { // find nearwest cross hZone level up Найти ближайшее пересечение кривой уровня hZone снизу вверх j=i+2; while(ExtMapBuffer1[j]>hZone && jOpen[hOpen]) hvar=hClose; else hvar=hOpen; } // put point (in the buffer) Поставить точку (в буфере) if(j-i>BarsCross) { // h[hvar]=High[hvar]+10*Point; h[hvar]=arrow_location; //find nearest points PointTotal - upper points Найти ближайшие PointTotal верхние точки FindCrossH(i); } } // if on last 2 bars lZone crossed down Если на двух последних барах кривая пересекает уровень lZone снизу вверх if(ExtMapBuffer1[i]>lZone && ExtMapBuffer1[i+1]BarsCross) { // l[lvar]=Low[lvar]-10*Point; l[lvar]=arrow_location; // nearest lower dots Найти ближайшие PointTotal нижние точки FindCrossL(i); } } // 4 d1 ДЛЯ ТФ D1 // Если на двух последних барах кривая пересекает уровень hZone сверху вниз if(ExtMapBuffer3[i]hZone) { // Найти ближайшее пересечение кривой уровня hZone снизу вверх j=i+2; while(ExtMapBuffer3[j]>hZone && jOpen[hOpen]) hvar=hClose; else hvar=hOpen; } // Поставить точку (в буфере) if(j-i>BarsCross) { // zD1h[hvar]=High[hvar]+10*Point; zD1h[hvar]=arrow_location; // Найти ближайшие PointTotal верхние точки FindCrossD1H(i); } } // Если на двух последних барах кривая пересекает уровень lZone снизу вверх if(ExtMapBuffer3[i]>lZone && ExtMapBuffer3[i+1]BarsCross) { // zD1l[lvar]=Low[lvar]-10*Point; zD1l[lvar]=arrow_location; // Найти ближайшие PointTotal нижние точки FindCrossD1L(i); } } if (!IsTesting() && Comments1) { Comment ("\nLast High "+PriceH[0]+" on Bar # "+ShiftH[0]+ "\nLast Low "+PriceL[0]+" on Bar # "+ShiftL[0]+ "\n\nPrevious High "+PriceH[1]+" on Bar # "+ShiftH[1]+ "\nPrevious Low "+PriceL[1]+" on Bar # "+ShiftL[1]); } } //---- return(0); } //+------------------------------------------------------------------+ //| searching history PointTotal last pois buff h[]Находит на истории PointTotal последних точек буфера h[] | //| & PointTotalи last points l[]PointTotal последних точек буфера l[]. | //| save glob var params 4 dots : Для каждой точки сохраняются в глоб. переменных след. параметры:| //| - смещения ShiftH[],ShiftL[]; | //| - цена PriceH[] (High[] для h[]), PriceL[] (Low[] для l[]) | //| | //+------------------------------------------------------------------+ void FindCrossH(int _Shift) { int i,j; int k; // для тестового вывода на печать // Обнуляем массивы for(i=0;i