Get exact value of an instrument at a given date

szotkowski

New member
Joined
Mar 25, 2020
Posts
2
Likes
1
Hello, I am curious how to get a price info from a date and hour - for example 3.3.2020 at 15.30 or 7 days before now. I mean to get the value on a 1-hour chart for example
 
Last edited:

Spin

Well-known member
Joined
May 22, 2019
Posts
478
Likes
191
Welcome to the MW Community, szotkowski ! :)

If you want exactly 7 days ago, you could use the ruler tool to count how many H1-bars ago that was.

My MW says there are 341 H1 candles between March 27 1500h and April 16 1500h. Your number might be different, because some brokers open sooner / later and close sooner / later than others.

You could then lookup when that bar started
Java:
 static Long time_7_days_ago;


time_7_days_ago = new long(series.getStartTime(index-341);

and use this 'time_7_days_ago' to draw on a chart.

Or just get that bar's info, like this:
Java:
High_7D_ago = series.getHigh(index-341);

Check this page on what info you can request:
https://www.motivewave.com/sdk/javadoc/com/motivewave/platform/sdk/common/DataSeries.html

Use
Java:
debug("price 7 days ago was " + High_7D_ago);
to output to your Study log to check whether your values are correct. :)


EDIT: for finer granularity you could work with the "getStartTime" and substract 7 days worth of miliseconds (= 604800000) from that number. And subsequently get values from the corresponding 1 minute bar.
 
Last edited:
Top