Calculate and plot average price per tick bar

Hi,

I'm new to AFL and have searched the forum but doesn't seem to find answer on how to do this

Setup:
Bar size = NT , let's say 5T

Datasource:
IQFeed tick data

Goal:
Calculate average price per tick bar

Example:
Bar1 tick prices = 1,2,3,4,5
Bar2 tick prices = 6,7,8,9,10

Average for Bar1 = 3
Average for Bar 2 = 8

Plot averages

Is there a way to calculate average price for a given bar?

Thank you

@dhwang141,
If you have searched the forum then you have seen the forum has rules. C'mon, man, at least make an effort...
Please follow this advice: How to ask a good question

1 Like

I can do program and but don't know where to start -- which AFL function(s) to use to parse and calculate tick data, hence I'm posting here. I've tried to illustrate my question as best as I can. Could you tell me which part of my question is not adhering to the forum rules?

Also, if this question is not suited for the community, but more for Amibroker support, then I apologize and will take the question offline and email support instead.

Your question is simply unclear and guessing games are not welcome.
Make your question CLEAR.

@dhwang141, if you want the average price for the bar

avgbarprice = (H+L)/2;

Thank you all for the replies. Let me rephrase the question then.

NQ#C

Above chart is using IQFeed tick datasource, symbol is NQ, chart interval is 50 ticks.

What I want to calculate is the average price for each bar --

Since each bar is 50 ticks, is there a way to calculate the sum of prices for all 50 ticks in the same bar (tick0 + tick1 + ... + tick49) then divide by 50 to get the average.

@snoopy.pa30 Thank you for the suggestion. (H+L)/2 gives me the midpoint price of the bar, not the average price of the bar.

To calculate intra-bar average of n-tick bar use TimeFrameMode() (mode 1) together with time frame functions on a 1-tick chart. Then you can flag longer interval bars and sum up prices within there (See Sum(), SumSince() functions) and result being divided by n.

15

Also reminder to you:

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.

@fxshrat Thank you. I will look into TimeFrameMode, TimeFrameSet, Sum and SumSince.

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