Download MetaTrader 5

Value of a historic close

To add comments, please log in or register

I am struggling to get a close from a historic bar, a bar from over 5 years ago.

I have the following code:


extern datetime   FromDate=D'2009.01.01 00:00';

extern datetime   DrawAtDate=D'2014.01.01 00:00';

I have 2 xmapbuffers

Then I draw the fromdate at the drawatdate

Of course there is a price difference between the 2 prices. So to get the historic price on the chart at the same level I need a multiplier. I call this the xfactor.

the xfactor = drawatdate/fromdate.  

The drawatdate is simple if it is the last close iClose[1].

The fromdate is where i struggle. How do I get that close?

I can deduct drawatdate-fromdate and call it x

Would the iClose fromdate be iClose[x]?

I don't think so because what about the weekends? And is it even possible to get an iClose from that far back? 

Help please.


Thinking about this a bit more, I wouldn't need the iclose[x] per se.

The value I am looking for is in the xmapbuffer and is the first value.

I imagine the array would store time and close and other values you would give it.

So, I could get the value from the first entry of both xmapbuffers.

How do I get the first value if for instance the array consists out of: [DATE] and [CLOSE]?

In other words, from the first record in the xmapbufer array I need the 2nd field only.


To add comments, please log in or register