How to make lines with high/low of one hour (not last) ---- HELP

 

Hi all,

I am coding me new breakout system and I have little problem with it.

I need two lines, one for low, one for high. I want to take this high, low from 5M chart between 9 and 10 hour.

Can you help me? Thank u soo much

 

LukasFX 

 
LukasFX:

Hi all,

I am coding me new breakout system and I have little problem with it.

I need two lines, one for low, one for high. I want to take this high, low from 5M chart between 9 and 10 hour.

Can you help me? Thank u soo much 

If your EA is not on the M5 chart then you will need to use iHigh() and iLow() to get the high and low of the highest and lowest bars between 9 and 10 am . . .  to get the Highest and Lowest bars use iHighest() and iLowest()


You haven't said what exatly you are having problems with ?  drawing the lines ?  calculating the High and Low,  working out when 9am and 10am are ? 

 

I propose you following code to define your line parameters :

string Start= "09:00";     //start time
string End= "10:00";       //End Time
datetime Time_S,Time_E;
datetime Now=TimeCurrent();//Server Time
int bar1,bar2;
double HighPrice,LowPrice; 


   Time_S= StrToTime(TimeToStr(Now, TIME_DATE)+" "+Start);
   Time_E= StrToTime(TimeToStr(Now, TIME_DATE)+" "+End);  
   bar1=iBarShift(Symbol(),TF,Time_S);
   bar2=iBarShift(Symbol(),TF,Time_E);  
   HighPrice=iHighest(Symbol(),0,MODE_HIGH,bar1-bar2,bar2); // the Highest of 09:00 to 10:00
   LowPrice=iLowest(Symbol(),0,MODE_LOW,bar1-bar2,bar2);    // the Lowest of 09:00 to 10:00

This code will give you the High price and Low price in the 09:00-10:00 interval

Hope it can help you :)

Kane.

 
RaptorUK:

If your EA is not on the M5 chart then you will need to use iHigh() and iLow() to get the high and low of the highest and lowest bars between 9 and 10 am . . .  to get the Highest and Lowest bars use iHighest() and iLowest()


You haven't said what exatly you are having problems with ?  drawing the lines ?  calculating the High and Low,  working out when 9am and 10am are ? 


Thank u for reply. My problem is how to calculate high and low. My EA will run on the 5M chart, and i do not know how to extract high and low from only one hour. Or a should use iHighest /iLowest from H1 chart. Is it easyer?

 
Oh i forget, "TF" located on
bar1=iBarShift(Symbol(),TF,Time_S);
is the TimeFrame Value.
 
LukasFX:


Thank u for reply. My problem is how to calculate high and low. My EA will run on the 5M chart, and i do not know how to extract high and low from only one hour. Or a should use iHighest /iLowest from H1 chart. Is it easyer?

 


Yes you can do like that to:

double High, Low

High= iHigh(Symbol(),PERIOD_H1,1)
Low= iLow(Symbol(),PERIOD_H1,1

So you have the high and Low of the lasr Candle. You have finally to write

if (time== X)

    Allow to Trade of Draw object.
 
Kane59:

I propose you following code to define your line parameters :

This code will give you the High price and Low price in the 09:00-10:00 interval

Hope it can help you :)

Kane.

Thank u, u really help me... 
 
It's possible that your two lines move during the interval time when the high and low move too. The two lines will be static when the interval time is ending.
 
Kane59:

I propose you following code to define your line parameters :

string Start= "09:00";     //start time
datetime Time_S,Time_E;
datetime Now=TimeCurrent();//Server Time
   Time_S= StrToTime(TimeToStr(Now, TIME_DATE)+" "+Start);
Or for efficiency:
#define HR2400      86400           // 24 * 3600
datetime TimeOfDay(datetime when){  return( when % HR2400          );       }
datetime DateOfDay(datetime when){  return( when - TimeOfDay(when) );       }
:
#define HR0900      32400
datetime Now=TimeCurrent();//Server Time
datetime Time_S = DateOfDay(Now)+HR0900;

Also needed is to handle the case where Now is before 9:00
if (Now < Time_S){         #define DOW_SUNDAY  0
   Time_S = iTime(NULL, PERIOD_D1, 1)+ HR0900;
   if (TimeDayOfWeek(Time_S) == DOW_SUNDAY) // Market opens 2200 Sunday
       Time_S = iTime(NULL, PERIOD_D1, 2)+ HR0900; // Use Friday
}
Reason: