User mistake: Why array stores lesser number of values than its size

Hi.. Please find the below code.

_SECTION_BEGIN("Title");
TimeFrameSet( in5Minute );
closeprices=Close;
printf("done");
_SECTION_END();

I debug the above code. And observed in the watch list for the values inside the "closeprices".
Please find the attachments.

-> Is in amibroker the array size is 200? if yes then how to resize the array?
->why the array storing only last 40 bars(159 to 200) close prices only ?
Close_1 Close_2 Close_3 Close_4 Close_5 Close_6 Close_7 Close_8

Because you did not restroe and expand.

_SECTION_BEGIN("Title");
TimeFrameSet( in5Minute );
closeprices=Close;
TimeFrameRestore();
closeprices = TimeFrameExpand(closeprices, in5Minute);
printf("done");
_SECTION_END();

Check out this one https://www.amibroker.com/guide/h_timeframe.html

2 Likes

Thanks for your quick help.
Please find the below code.

_SECTION_BEGIN("Title");
TimeFrameSet( in5Minute );
closeprices=Close;
//TimeFrameRestore(); // commented because if i use this i am getting 1 minute data.But i want 5 minute data
closeprices = TimeFrameExpand(closeprices, in5Minute);
printf("done");
_SECTION_END();

->If i comment the "TimeFrameRestore(); " and run the program in debug mode then getting the Data/Time in invalid date/Time for first 160 rows. How to get the correct date/Time?

Please find the attached screen shots.ami_1 ami_2 ami_3 ami_4 ami_5 ami_6 ami_7 ami_8 ami_9

You should not comment TimeFrameRestore.

Please find the attachment. See if i did not comment i am getting 1 minute data. Please find the attached screen shot .Getting data as 12:11, 12:12, 12:13, 12:14, 12:15 etc...
timeframe

But i need 5 minute timeframe only.

@Kum001 Didn't you notice, that each 5 (1-minute bars) have the same closing price?

Image%201

Why? Because that's how 5 minute data looks in 1 minute timeframe.

You really need to understand how timeframe functions work and it is described in details in AB documentation. Besides you can find dozens of different codes using timeframe functions on the forum. Don't expect from other users repeating what you can easily find following the link given to you by @codejunkie . Just spend some time reading the documentation and analysing the examples.


Besides do you really need timeframe functions? if you need 5 minute data, simply change the chart's interval to 5-minute.

Image%205

1 Like

@Kum001 - I have no idea HOW on earth I can make people READ at least orange boxes in the users manual: https://www.amibroker.com/guide/h_timeframe.html

The orange boxes in the manual are used to highlight sections that you MUST READ. And you completely skipped/ignored that. So read the orange boxes in https://www.amibroker.com/guide/h_timeframe.html . All of them. From beginning to end and carefully/slowly. Once you do you will find out everything you did wrong in your formula.

1 Like

Thanks @Tomasz @codejunkie @Milosz for your responses.