# Highest price of few last bar

13
2014.07.14 09:45

Hi!

That's my first post, so let me welcome everyone.

I have found few topics about my issue, but nothing helped so far. While working on my ea, I would like to get Highest price of last 4 bars. That's my code:

if(Hour()==10)

{

int bar=iBarShift(Symbol(),PERIOD_H1,TimeCurrent());

a=High[iHighest(Symbol(),PERIOD_H1,MODE_HIGH,4,0)];

}

And than:

if((price+0.005)>a &&Hour()>9&&Hour()<16&&czy!=true)

Ea does strange things. It buys sometimes above High of the last bar, sometimes in area, which isnt't connected with any particular level of price. What is wrong?

Cheers

3243
2014.07.14 10:49

if you are not using H1 TF you can't use High[xxx] you have to use iHigh:

`iHigh(Symbol(), PERIOD_H1,iHighest(Symbol(),PERIOD_H1,MODE_HIGH,4,0))`

B.T.W. what is the use of

`int bar=iBarShift(Symbol(),PERIOD_H1,TimeCurrent());`

13
2014.07.14 13:46
I tried all variations with High[], iHigh(). Could anyone give me further explenation what should I do?
14742
2014.07.14 13:55
What qjol said
 Your code `a=High[iHighest(Symbol(),PERIOD_H1,MODE_HIGH,4,0)];` Break it down ```int    iHH_H1 = iHighest(Symbol(),PERIOD_H1,MODE_HIGH,4,0); double  HH_H1 = iHigh(   Symbol(),PERIOD_H1,iHH_H1);```iHH_H1 is the index on the H1 chart. High is the chart's timeframe, not H1. You can't use High[iHH_H1] Don't mix apples and oranges. You also don't need to look at the H1 ```datetime now = Time[0]; datetime fourHours = now - 4 * PeriodSeconds(PERIOD_H1); int      iFour     = iBarShift(NULL,0, fourHours); int    iHH    = iHighest(NULL,0, MODE_HIGH, iFour+1, 0); double  HH    = High[iHH];```Compute when. Find that chart bar. Find the highest on your chart [0 .. iFour] inclusive. Get the high from the chart. No other TF needed.
Moderator
9639
2014.07.14 13:57
Michocio:
I tried all variations with High[], iHigh(). Could anyone give me further explenation what should I do?

Well, you could answer gjol's question.

Also with your snippet of code

`if((price+0.005)>a &&Hour()>9&&Hour()<16&&czy!=true)`

we have no idea where the variables "price" and "czy" come from.

3243
2014.07.14 14:05
GumRai:

Well, you could answer gjol's question.

did I said already that I'm tired ?

13
2014.07.14 14:30

As I said I found a lot of topics about that issue but nothing works. Big thank for everyone for help but even table from WHRoeder post didn't help me. Please take a butcher's on that code :

{

if(ticket<0)

{

Print("OrderSend failed with error #",GetLastError());

}

else

Print("OrderSend placed successfully");

}

Where HH is from gjol's code.

EA still makes order in wrong moments

14742
2014.07.14 18:17
Michocio:

but nothing works. Big thank for everyone for help but even table from WHRoeder post didn't help me. Please take a butcher's on that code :

`iHigh(Symbol(), PERIOD_H1,iHighest(Symbol(),PERIOD_H1,MODE_HIGH,4,0))`