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. |
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.
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(Ask>HH &&Hour()>9&&Hour()<16)
{
int ticket=OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Bid-0.005,Bid+0.015,"My order",16384,0,clrGreen);
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
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 :
Where HH is from gjol's code.
iHigh(Symbol(), PERIOD_H1,iHighest(Symbol(),PERIOD_H1,MODE_HIGH,4,0))
- "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
Play videoPlease edit your post.
For large amounts of code, attach it.
- HH is the highest BID. What happens when when the Bid approaches HH? Ask becomes above HH and you open.
- If you change to Bid > HH you have another problem. What happens when Bid exceeds HH? HH increases because you are using bar zero
What qjol said
Your code | |
Break it down | 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 | 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. |
super explanation

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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?
Please, help me.
Cheers