You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
//+------------------------------------------------------------------+ //| PrevDayHiLo.mq4 | //| Tyrone Faulkner - May 2007| //| Show the High and Low for the previous day| //+------------------------------------------------------------------+ #property copyright "Tyrone Faulkner" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 LightBlue #property indicator_color2 Salmon //---- Input Parms extern int HiLoMarker=30; //---- buffers double DayHi[]; double DayLo[]; //---- Global variables double dHigh = 0.000000, dLow = 999999.999999; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,DayHi); SetIndexDrawBegin(0,0); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,DayLo); SetIndexDrawBegin(1,0); //---- int counted_bars=IndicatorCounted(); int pos; //---- check for possible errors if (counted_bars<0) return(-1); //---- datetime dayChk = TimeDayOfWeek(Time[0]); datetime dayChkHld; //---- Find previous days high and low for(pos=1;pos<Bars;pos++) { dayChkHld = TimeDayOfWeek(Time[pos]); if (dayChkHld != dayChk && dayChkHld != 0 && dayChkHld != 6) //---- Find previous day which is not a Saturday or Sunday { if(High[pos] > dHigh) dHigh = High[pos]; if(Low[pos] < dLow) dLow = Low[pos]; if(TimeDayOfWeek(Time[pos+1]) != dayChkHld) pos = Bars; //---- Test for end of previous day } } return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- Put your code here //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); int pos; if (counted_bars == 0) pos = HiLoMarker-1; else pos = Bars - counted_bars - 1; while(pos>=0) { DayHi[pos] = dHigh; DayLo[pos] = dLow; if (counted_bars>0) //---- Roll the High Low markers forward. { DayHi[pos+HiLoMarker] = EMPTY_VALUE; DayLo[pos+HiLoMarker] = EMPTY_VALUE; } pos--; } //---- return(0); } //+------------------------------------------------------------------+