Detecting breaches.

 

Hello,


I have an array of 200 candlesticks for EUR/USD 1hr chart. How can I detect breaches using mql5? Please help.

 
TheGeek:

Hello,


I have an array of 200 candlesticks for EUR/USD 1hr chart. How can I detect breaches using mql5? Please help.

Breaches of what?

 
Keith Watford:

Breaches of what?

I guess he meant a breakout ?
 

You can query the highest/lowest price of a series of candles and then check if the actual price surpasses it.

int lookback=20; // 20 candles
int start=1; // starting from the last one

int shift=iHighest(_Symbol,_Period,MODE_HIGH,lookback,start);
double localHigh=iHigh(_Symbol,_Period,shift);
if(Bid>localHigh)
  {
   // breakout
  }

shift=iLowest(_Symbol,_Period,MODE_LOW,lookback,start);
double localLow=iLow(_Symbol,_Period,shift);
if(Bid<localLow)
  {
   // breakout
  }