Lucky millionaire trader
Peak and Trough indicator - someone help make this indicator 2 replies
Please help turn this price channel indicator to MTF indicator 0 replies
Please help to change this indicator into MTF indicator 3 replies
help, help, help (templates) 5 replies
Help, Help, Help 3 replies
//+------------------------------------------------------------------+ //| HighLow_Custom.mq4 | //+------------------------------------------------------------------+ #property indicator_chart_window #property indicator_buffers 5 #property indicator_color1 DodgerBlue #property indicator_color2 Chocolate #property indicator_color3 DodgerBlue #property indicator_color4 HotPink #property indicator_color5 HotPink //---- indicator buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double ExtMapBuffer4[]; double ExtMapBuffer5[]; extern string Time_Frame_value = "0,M1,M5,M15,M30,H1,H4,D1,W1,MN1"; extern string Time_Frame = "D1"; int timeFrame; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { if (Time_Frame == "M1") { timeFrame = PERIOD_M1; } else if (Time_Frame == "M5") { timeFrame = PERIOD_M5; } else if (Time_Frame == "M15") { timeFrame = PERIOD_M15; } else if (Time_Frame == "M30") { timeFrame = PERIOD_M30; } else if (Time_Frame == "H1") { timeFrame = PERIOD_H1; } else if (Time_Frame == "H4") { timeFrame = PERIOD_H4; } else if (Time_Frame == "D1") { timeFrame = PERIOD_D1; } else if (Time_Frame == "W1") { timeFrame = PERIOD_W1; } else if (Time_Frame == "MN1") { timeFrame = PERIOD_MN1; } else { timeFrame = 0; } if (timeFrame < Period()) { Alert("The timeframe must be higher than the current"); deinit(); } SetIndexBuffer(0, ExtMapBuffer1); SetIndexStyle(0, DRAW_LINE); SetIndexBuffer(1, ExtMapBuffer2); SetIndexStyle(1, DRAW_LINE); SetIndexBuffer(2, ExtMapBuffer3); SetIndexStyle(2, DRAW_LINE); SetIndexBuffer(3, ExtMapBuffer4); SetIndexStyle(3, DRAW_LINE); SetIndexBuffer(4, ExtMapBuffer5); SetIndexStyle(4, DRAW_LINE); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { Comment(""); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int shift, i, CurDay, BarCount; double DayMax, DayMin; double DayOpen, DayClose, Avg; for (shift=Bars-1; shift>=0; shift--) { int timeFrameIndex = iBarShift(NULL, timeFrame, Time[shift], true); if (CurDay != iTime(NULL, timeFrame, timeFrameIndex)) { for (i=BarCount; i>=0; i--) { ExtMapBuffer1[shift+i] = DayMax; ExtMapBuffer2[shift+i] = (DayMax+DayMin)/2; ExtMapBuffer3[shift+i] = DayMin; ExtMapBuffer4[shift+i] = (DayMax+DayMin)*0.25; ExtMapBuffer5[shift+i] = (DayMax+DayMin)*0.75; } CurDay = iTime(NULL, timeFrame, timeFrameIndex); BarCount = 0; DayMax = 0; DayMin = 1000; DayOpen = Open[shift]; } if (DayMax < High[shift]) { DayMax = High[shift]; } if (DayMin > Low[shift]) { DayMin = Low[shift]; } BarCount = BarCount + 1; } for (i=BarCount; i>=0; i--) { ExtMapBuffer1[shift+i] = DayMax; ExtMapBuffer2[shift+i] = (DayMax+DayMin)*0.50; ExtMapBuffer3[shift+i] = DayMin; ExtMapBuffer4[shift+i] = DayMin + (DayMax-DayMin)*0.25; ExtMapBuffer5[shift+i] = DayMin + (DayMax-DayMin)*0.75; } DayClose = Close[0]; Avg = (DayMax+DayMin)/2; return(0); } //+------------------------------------------------------------------+ /* Comment( "DayMin " , DoubleToStr(ExtMapBuffer3[0], Digits), "n", ".25 " , DoubleToStr(ExtMapBuffer4[0], Digits), "n", ".50 " , DoubleToStr(ExtMapBuffer2[0], Digits), "n", ".75 " , DoubleToStr(ExtMapBuffer5[0], Digits), "n", "DayMax " , DoubleToStr(ExtMapBuffer1[0], Digits), "n", "" ); */
//+------------------------------------------------------------------+ //| dayHL_Average.mq4 | //+------------------------------------------------------------------+ /* Name := dayHL_Average Author := KCBT Link := http://www.kcbt.ru/forum/index.php? */ #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 Red #property indicator_color3 Red //---- input parameters5 extern int show_comment=1; // рисовать ли комментарий (0 - нет, 1 - да) extern int how_long=1000; // сколько баров обрабатывать (-1 - все) //---- indicator buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { SetIndexBuffer(0, ExtMapBuffer1); SetIndexStyle(0, DRAW_LINE); SetIndexBuffer(1, ExtMapBuffer2); SetIndexStyle(1, DRAW_LINE); SetIndexBuffer(2, ExtMapBuffer3); SetIndexStyle(2, DRAW_LINE); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { Comment(""); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { int cnt=0; // счетчик баров int begin_bar=0; // бар, с которого начинает работу индикатор int prev_day, cur_day; // идентификаторы текущего и предыдущего дня double day_high=0; // дневной high double day_low=0; // дневной low double yesterday_high=0; // наибольшая цена предыдущего дня double yesterday_low=0; // наименьшая цена предыдущего дня double yesterday_close=0; // цена закрытия предыдущего дня double P, S, R; // правильные таймфремы для нашего индикатора - все, что меньше D1 if (Period()>=PERIOD_D1) { Comment("WARNING: Invalid timeframe! Valid value < D1."); return(0); } // решаем с какого бара мы начнем считать наш индикатор if (how_long==-1) { begin_bar=Bars; } else { begin_bar=how_long; } // обходим бары слева направо (0-й бар тоже используем, т.к. из него мы берём только high и low) for(cnt=begin_bar; cnt>=0; cnt--) { cur_day=TimeDay(Time[cnt]); if (prev_day!=cur_day) { yesterday_close=Close[cnt+1]; yesterday_high=day_high; yesterday_low=day_low; P=(yesterday_high + yesterday_low )/2; R=yesterday_high; S=yesterday_low; // т.к. начался новый день, то инициируем макс. и мин. текущего (уже) дня day_high=High[cnt]; day_low=Low[cnt]; // запомним данный день, как текущий prev_day=cur_day; } // продолжаем накапливать данные day_high=MathMax(day_high, High[cnt]); day_low=MathMin(day_low, Low[cnt]); // рисуем pivot-линию по значению, вычисленному по параметрам вчерашнего дня ExtMapBuffer2[cnt]=P; // рисуем линии сопротивления и поддержки уровня 1,2 или 3 ExtMapBuffer1[cnt]=R; // сопротивление ExtMapBuffer3[cnt]=S; // поддержка } if (show_comment==1) { P=(yesterday_high + yesterday_low )/2; R=yesterday_high; S=yesterday_low; Comment("Current H=", R, ", L=", S, ", HL/2=", P, ", H-L=", (R-S)/Point ); } return(0); } //+------------------------------------------------------------------+