# How can we calculate highest and lowest candle close between specifed EA working hours

One of my expert advisor is running only between 09.30-18.10 hours.

I want to find, in 1 minute chart, highest and lowest candle close between that hours, anyone can help me?

Here is some code:

...

input int      robotCalismaSaati = 09;  //Ea start hour
input int      robotCalismaDakikasi = 30; //Ea start minute
input int      robotDurmaSaati = 18;  //Ea stop hour
input int      robotDurmaDakikasi = 10; //Ea stop minute

int someIndicatorDefinition;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
someIndicatorDefinition = iCustom(Symbol...

return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{

}
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
//--- we work only at the time of the birth of new bar
static datetime PrevBars=0;
datetime time_0=iTime(0);
if(time_0==PrevBars)
return;
PrevBars=time_0;

MqlDateTime islemzamani;
datetime zaman = TimeCurrent();
TimeToStruct(zaman,islemzamani);
int robotAnlikZaman = (islemzamani.hour*3600) + (islemzamani.min*60);
ZeroMemory(islemzamani);

double closeM1[];
ArraySetAsSeries(closeM1,true);
CopyClose(Symbol(),PERIOD_M1,0,5,closeM1);

double ... [];
ArraySetAsSeries (...,true);
CopyBuffer(someIndicatorDefinition,3,0,100,...);

//Sell  Close ---------------------------------------------------------------------------------------------
if(
(closeM1[1] > ...[1])
||
)
if(sell_islem_sayisi>0)
ClosePositions(POSITION_TYPE_SELL);
if(
( closeM1[1] < ...[1] )
||
)

if(
&& sell_islem_sayisi==0
)
{
if(

&&
closeM1[1] > Highest m1 candle of robot start hours & minutes  <------------------------------------------------------------------

)
{
if() {}
}

// Open sell: ----------------------------------------------------------------------------------
//--- check condition on SELL
else
if (
&&
closeM1[1] < Lowest m1 candle of robot start hours & minutes  <------------------------------------------------------------------
)

{
if() {...}
}
}

{
//---

}

...

Cuneyt Ates: