Hi,
I’m trying to run a bit of code in “Exploration” where I want to get the time of the latest Quote.
A very similar function that I’ve read of is GetRTData(“UpdateTime”) but this works only for RT Data sources and not local DB.
The periodicity that I require in the Explore is “Daily”, so when I use functions like Hour() or Minute() they return the daily opening time of the (daily) bar.
I know you can use TimeFrameGetPrice() of a different interval but is there any way to reference the time of such array.
Currently I have 1m data of the symbols.
A practical scenario where I want to use this is to AddTextColumn and display the difference in time: Now() - LatestQuoteTime
Maybe you can learn and take from this code to get you started…
// Created by: Sean O'Neill 04/18/2013
// Explore to calculate and see how old i.e., how many days ago
// the last data was recorded for the instrument symbol. Tricky and
// need to get all date/time variables into the same format (Unix Seconds)
// so we can get the correct comparison.
lastSymbolDateNum = DateTimeConvert(format = 2, DateNum() );
dateNowNum = DateTimeConvert(format = 2, Now(format = 3) );
SecsSinceUpdateNum = DateTimeDiff(dateNowNum, lastSymbolDateNum);
DaysSinceUpdateNum = SecsSinceUpdateNum / 86400;
lastSymbolDateStr = NumToStr( lastSymbolDateNum );
dateNowStr = NumToStr( dateNowNum );
SecsSinceUpdateStr = NumToStr( SecsSinceUpdateNum );
DaysSinceUpdateStr = NumToStr( DaysSinceUpdateNum );
//AddTextColumn( lastSymbolDateStr, "Last Symbol Date Num");
//AddTextColumn( dateNowStr, "DateNow Num");
//AddTextColumn( SecsSinceUpdateStr, "Seconds Since Updated");
AddTextColumn( DaysSinceUpdateStr, "Days Since Updated");
Filter = DaysSinceUpdateNum > 60.00; //True;
returns s1 as the daily opening time of the bar say: 9AM as 90000 (90000 is correct)
What I need is the time of the last quote, in my case, which is 1m Data stored in the Quotes.
its the same as using Hour() or Minute() but the challenge is all these functions refer to the Daily bar values OPEN values.
is there a way of getting the closing time of the bar? That might return the latest time.
Thanks for the reply.
I’ve spent a lot of time reading the guide and all the functions.
I’ve tried LastValue and EndValue() functions as well and I still get the daily bar open time being returned by both the functions.
The catch is periodicity in Exploration is set to Daily, if I change it to 1M (1 minute) then any of the functions mentioned above like Hour(),Minute() DateTime() TimeNum() etc all return the latest tick value.
But when periodicity is set to Daily, even if the functions are run within a TimeFrameSet(60) … TimeFrameRestore() block, I still get the daily bar value.
Since I’m not computing anything in that block, I don’t see the need of TimeFrameExpand etc to be used.
A string variable is populated in the block and used in AddTextColumn at the end.
You will get start of interval because you have set it so in Tools->Preferences->Intraday
"Time compressed bars".
If you use “start of interval” you will get opening time, if you use “end” you will get ending time.
You can change it to suit your needs or you can use simply add the interval to the timestamp you are getting, using DateTimeAdd.
Or you can use Status function http://www.amibroker.com/guide/afl/status.html