Getting the Close value of a specific Bar

 

I'm trying to locate the value in a specific Bar and I dont really understand how to work with Arrays.

When I try to read a "Bars[bar_number]" value, it returns that it needs an integer value as index.

My "bar_number" in this example is a value that I get from the iHighest function.

How can I get the value contained in "bar_number" into the Bars Array index?

EX: bar_number=iHighest(a,b,c,d etc..)

result = Close[bar_number]


Can anyone explain to me how to get that value?

and I would appreciate a Link to where I could read about "Arrays How-To".

Thank You .

 
 
Micky52:
...

EX: bar_number=iHighest(a,b,c,d etc..)

result = Close[bar_number]

....

Not sure how you are using iHighest() but it returns a shift from the current bar to the highest bar between two points

https://docs.mql4.com/series/iHighest

So if you are using iHighest correctly, your result should be fine.

V

 
Viffer:

Not sure how you are using iHighest() but it returns a shift from the current bar to the highest bar between two points

https://docs.mql4.com/series/iHighest

So if you are using iHighest correctly, your result should be fine.

V


Hi Viffer,

As you say, iHighest returns to me the Bar number of the highest bar in that range, but in my "bar_number" variable.

What I want to know, is how to get that value in Close[].

IE: Close[bar_number]

but MQL wont allow a variable as an index, How can I get the value of bar_number transferred into the index of Close?

Thanks

 

Thanks UBZen for your link, very informative, but could not find an answer to my problem.

EX: bar_number=iHighest(a,b,c,d etc..)

double result = Close[bar_number]


Lets say bar_number = 5, I need to enter this value "5" into the index of CLOSE.

??

Micky

 
Micky52:
...

but MQL wont allow a variable as an index, How can I get the value of bar_number transferred into the index of Close?


Yes it does... do it just as you have shown... but make sure your variable is declared as an int.

or do it like this (highest of last 20 bars)

result =iClose(Symbol(),Period(),iHighest(Symbol(),Period(),MODE_HIGH,20,0)); 

If it still doesn't work, post the code and we can take a look.

V

 
  1. iClose(Symbol(),Period(),x) is identical to Close[x]
  2. In the tester, you only get 100 Bars initially. Make sure your x < Bars
  3. Post your code.
 
We are one of the worlds MOST popular Jerseys trading companies on the world. Learn more about [URL=http://www.jerseysusa.com]replica jerseys[/URL] or [URL=http://www.jerseysusa.com]cheap nfl jerseys[/URL] for Sports Fans,please feel free to click my site.thanks.
 

Hi everyone, sorry for the delay,

Here's what I came up with, and it works...

double result=High[iHighest(0,x,x,x...)];

This way I get the Highest value of a range.

High is of double type

iHighest is of Int type.

Thanks to you all for your help and support.

Micky