How to get close prices of today's date

Hi..

I want to get close prices of today's date 5 minute time frame.I am using the below code.
_SECTION_BEGIN("debug amiforum");
TimeFrameSet( 5*in1Minute ); // switch to 5 minute frame
close_prices=Close;
_SECTION_END();

But the array close_prices giving the array with index 0 to 199 and 0 to 159 as null values.Remaining 40(160 to 199) values as the latest close prices.
-> I need only today's close prices with out having any null values in the array. Means Array size should be the number of 5 minute bars in the today's date.

What changes should i do in my code.

@Kum001 I am not sure I understand your problem. Today's close is the closing price of the last bar today irregardless of the time frame your analysis or chart is using.

so in your analysis just run an Explore and see the Close.
image

If you are using some logic that requires multiple time frame analysis then you must read and learn,
https://www.amibroker.com/guide/h_timeframe.html

In that case you can play around with some values like this for an Explore,

CurrentBarClose = Close;
YesterdayDailyClose = TimeFrameGetPrice( "C", inDaily, -1 );
TodayDailyClose = TimeFrameGetPrice( "C", inDaily, 0 );

/* 

if shift = 0 compressed data may look into the future 
( for example, Weekly high can be known on Monday and same with Intraday data - be careful how you use that ). If you want to write a 
trading system using this function please make sure to reference 
PAST data by using negative shift value.

*/

image

I've been off the forum for so long I can't resist adding completely unrelated trivia. Feel free to ignore the rest of this post...

/////////// an unrelated fun fact ///////////////
One word that gets a lot of vitriol is the word "irregardless." There is a dictionary entry for "irregardless." "Irregardless" is a word. This inspires specific vehement hatred in people. "Irregardless" is a word and we're duty-bound to enter it.

"Irregardless" is a word. It is related to "regardless." It is actually a blend of two words. It's a blend of "irrespective" and "regardless." People hate it because they say that it has no use — why not just use "regardless"?

But actually in the dialect that "irregardless" comes from, it has a specific use that doesn't translate well in print. It's basically an emphatic use of "regardless." So if you're a native speaker of certain dialects that use "irregardless" you use "irregardless" to shut down further conversation on a topic.

I might say, "Dad, let me borrow the car. I'm a really good driver." And he'll say, "Regardless, I'm not comfortable." I'll say, "Oh but come on. I'll get it detailed, and I'll put gas in it." He'll say, "Irregardless, no."_

The point of the "irregardless" is to shut down conversation. So "irregardless" is a word. It has a specific use, in particular dialects. That said, it's not part of standard English and so — especially if you're writing or if you're speaking in formal places — you want to use "regardless" instead. Because if you use "irregardless," people will think you're uneducated.

2 Likes

@Kum001 I may have completely misinterpreted your question. You start writing something that I do not understand at all.

What are you trying to accomplish? If you just want the close (5 minute bars) for one day then here (with nulls that you seem to be afraid of) is on example Exploration.

SpecificDate = DateNum()==1180104 ; 
// now you get a value ONLY on 2018-01-04, Jan 4, 2018
specificDateONLY = IIf(SpecificDate, Close, Null);

Filter=1;
AddColumn(C, "Close");
AddColumn(specificDateONLY, "January 4th Only");

Producing

image

Sorry if neither answer is of any help but perhaps if you elaborate on your question, someone else may help you. Irregardless :rofl: I'm out.

1 Like

@portfoliobuilder Thanks for your response. I am simplifying my requirement.

_SECTION_BEGIN("debug amiforum");
TimeFrameSet( 5*in1Minute ); // Now it will be in 5 minute timeframe
SpecificDate = DateNum()==180810 ; // I specified that which date we required the values
Close_prices=(SpecificDate,close);// This line is wrong please correct this line .I want only aug 10 2018 close prices in 5 minute candles. So the array should contain only aug 10 2018 candles (5 minutes) .Even null values i am fine
Filter=1;
AddColumn(Close_prices, "Close");
_SECTION_END();

@Kum001 you have not read or not understood the multiple timeframe coding syntax. You could have a TimeFrameSet

TimeFrameSet( in5Minute ); // switch to 5 minute frame

But you have no TimeFrameRestore.

TimeFrameRestore(); // restore time frame to original

Then you must understand the use of TimeFrameExpand and experiment with expandPoint vs expandFirst vs expandLast to obtain your desired result.

Also your August 10th is coded improperly so you need to read

https://www.amibroker.com/guide/afl/datenum.html

Lastly you are NOT FOLLOWING the forum rules concerning proper formatting of code samples.

Once you have mastered those steps come back with some attempted solutions and specifics of what you are trying to achieve and hopefully someone on the forum can help.

Good luck.

1 Like