Timeframe question

I have a 1-min bar DB and am working on a 15-min chart. I understand AFL doesn't allow changing timeframe to 1min, and that makes sense for most cases. However, if I just want to get a max or min or cum of something in the 1-min timeframe, is there anyway to do it? For example, can I get the sum of the effective volume of the 15 1-min bars? Thanks.

@JTrader , this forum contains a wealth of information. The SEARCH feature is your friend.

As you have been a member for over a year, and have only read for 40 minutes, I think you can learn a ton by spending some time reading.

Searching on Multi-timeframe and Volume should give you the results you need.

Like all good mentors, the ones here want to see that you have put some effort in before giving guidance. Most don't want to become someone's AFL code writing service.

2 Likes

I've been using amibroker for over 15 years so I know a lot more than what you think I know. And I did search the forum but didn't find any similar questions. Apparently you don't understand my question.
And if you really have the time checking on my profile, it'd be more productive to answer some questions here than whining around.

2 Likes

@JTrader I think your response is not polite while @snoopy.pa30 was trying to be helpful to someone who did not appear to have much experience with AmiBroker. He gave you some tips on researching MTF functions and searching the forum. He was not being rude or insulting. And he has attempted to help many users on this forum.

You claim to be a 15 year user, but how many times have you offered to help members of this forum? Zero?

I am no expert on intraday data manipulation but if you want to use 1 minute data then you must use the 1 minute interval in your analysis or charting. From there you can create your 15 minute bars or indicators if necessary.

A couple of different ways to accomplish this,

One way,

TimeFrameSet( in15Minute ); // switch to 15 minute frame
// do your 15 minute calculations in here
TimeFrameRestore(); // restore time frame to original

Another way,

dn = Day();
newDay = dn != Ref( dn, -1 );

CumVolToday = Sum(V, BarsSince(newDay)+1); // this will be calculated on the 1 minute data

o15 = TimeFrameGetPrice( "O", in15Minute, 0, expandPoint ); 
h15 = TimeFrameGetPrice( "H", in15Minute, 0, expandPoint ); 
l15 = TimeFrameGetPrice( "L", in15Minute, 0, expandPoint ); 
c15	= TimeFrameGetPrice( "C", in15Minute, 0, expandPoint ); 

And plotting the 1 minute volume calculation in a 1 minute chart but the OHLC bars are base upon 15 minute data.
image

Or zoomed out a bit
image

I hope that helps you.

6 Likes

I only found this forum and registered not too long ago so I haven't spent much time here yet.

I don't like his attitude of blaming me not doing my due diligent before posting for help. I searched before posting but didn't find any similar questions. Apparently he doesn't understand my question at all and just accused me out of nowhere. Enough said.

As to your code, as I mentioned in my post, I'm working in a 15-min chart, not a 1-min chart so your solution doesn't help. I know how to use timeframe and I also mentioned in my post that I understand that AFL doesn't allow accessing shorter interval (1-min in this case) data and that does make sense in most cases. I'm simply asking for 1 value of the 15 1-min bars so I thought there might be a way to do it. Hope I made it clear. Thanks.

1 Like

Was the question properly answered?

I understood that you were in the 15m timeframe and would like the volume or cum of 1m bars.

In that way, timeframeset() can not help but there are other ways.

Please, let us know if the doubt remains.

@JF_Derzi No, my question was not answered. Basically I'm trying to find a way to access a single data of short interval. Thanks.

@portfoliobuilder answered your question perfectly.

And the answer is that you MUST do things the OTHER way round, i.e. If you want to access ANYTHING in 1-minute interval you have to work with 1-minute chart (or finer interval) When doing so you will be able to do calculations in 1-minute, 15-minute or any N-minute interval.

It is very clearly explained in the Users' Guide orange boxes:
http://www.amibroker.com/guide/h_timeframe.html

PLEASE NOTE that you can only compress data from shorter interval to longer interval. So when working with 1-minute data you can compress to 2, 3, 4, 5, 6, ....N-minute data. But when working with 15 minute data you can not get 1-minute data bars. In a similar way if you have only EOD data you can not access intraday time frames.

So the answer, is NO, you cannot access 1-minute data when your current chart selected interval is 15-minute. You can however do the other way: access 15-minute data when your current selected interval is 1-minute, as @portfoliobuilder perfectly explained.

3 Likes

@Tomasz Thanks for the confirmation. As I said in my 1st post, I understood the restriction. I just thought it's a reasonable request to access a SINGLE data out of the 15 1-min bars; but if AFL doesn't support it that's fine, I will just have to deal with it.

Just curious, in a 1-min DB, how does AFL get larger interval information? Doesn't it access each 1-min bar and assemble them together? And is that functionality only available inside the engine but not to the user?

I have sent you another way to do that yesterday.
It is waiting for the admin approval.

There are two ways to do that.

The first one was already explained by Tomasz.

As Timeframeset() can only access higher and multiple timeframes, you could use a 1m chart and access any TF you want: 2m, 3m, 5m, 15m, anyone.
If you use a 2m chart, you would be able to access only 4m, 6m, 8m, 10m and so on.
Ok, those are the basics and you already know it, as you wrote it yourself on your question.

So, using a 1m chart and using timeframeset(in15minute) is one way to get the job done. You would do all your coding on the 1m chart and use the timeframe-functions to know anything you need about the 15m.

The second way is a little trick: you could use static vars.

You could have two charts, the 15m chart that you already have, and, a second 1m chart calculating whatever you want and storing the values/arrays in staticvars().

You can access the staticvars on the 15m chart and use them as you please. But notice that the staticvars could change their value during the formation of the 15m candle (after all, one 15m bar has 15 1m bars).

This second way is specially useful to use timebased timeframes and non-timebased (volume bars, range bars, renko...).

In that way, you could know if the 1m chart is out of its bollinger bands (or was out and now is in), or the volume of the last 15 1m bars that are not necessarily the volume of one 15m bar.

2 Likes

@JF_Derzi You have a very interesting and promising idea. I will look into it this weekend. Thanks.

@JF_Derzi Thanks for the information, it works! This is exactly what I need. Looks like in a longer time frame, staticvarget() gets the last bar value set in a smaller timeframe.
@Tomasz this is a very helpful feature and I believe many users would love to use it if it's documented.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.