Tick to OHLC conversion by AFL on the fly...?

Good day!

Is it possible to do an “on the fly” conversion of Tick data (currently using eSignal onDemand) to any -compressed at candle (OHLC) resolution- in order to not have a bloated database? Im looking to make one EOD download at nights of all day session from ticks but only need this in favor to have a final calculation not found in traditional OHLC data feeds, using traditional Amibroker’s internal database to store data as following this criteria:

Session could be minute, hour or EndOfDay based.
ALGO = Could be MoneyFlow defined as: (Last * TradeSize) or pure tick count defined as: cum(Last)

O = First Last value of session.
H = Max(Last) value of session.
L = Min(Last) value of session.
C = Last of session.
V = sum of all TradeSize of session.
Use this fields of Ami’s database as:
OInt = if Last == Last[1] then sum(ALGO)
AUX1 = if Last > Last[1] then sum(ALGO)
AUX2 = if Last < Last[1] then sum(ALGO)

So, OInt could have Unchanged Issues count of MoneyFlow or ticks, AUX1 Advanced issues and AUX2 Declining issues. With this additional fields in database, I hope to make interesting own Breath composites with Amibroker’s internals for each industry, sector, market, etc.

OHLCV could be grabbed directly from datafeed vendor as for splits, earnings, any other fundamental adjustments at price.

If someone here already done something similar or this exact thing I will be glad to receive proper help for my own research and development (I like to learn) or if proprietary, gladly could talk for the proper retribution if helpful.

Cheers and sorry for my rusty english guys.


You can do that conversion via AddToComposite() function.
Not need to export and re-import.

I’m not going into detail about your specific case but below is an example to convert data fields to different interval from base time interval (in your case 1-tick).

Suppose you have multiple months of 1-tick data but all you need is 1-min (or any other) resolution.
So in order to decrease DB size all you need to do is using AddToComposite (ATC) feature.

Step by step procedure (again, an example code):

  1. save below sample ATC code as AFL
// Choose name of ATC created symbol. 
// Tilde in front is mandatory for creation
indexname = "~" + Name() + "_OHLC_" + Interval(2);

SetOption( "RefreshWhenCompleted", True );

if ( Status( "action" ) == actionScan ) {
    Buy = 0;
    atcmode = atcFlagDefaults; 
    AddToComposite( Open, indexname, "O", atcmode );
    AddToComposite( High, indexname, "H", atcmode );
    AddToComposite( Low, indexname, "L", atcmode );
    AddToComposite( Close, indexname, "C", atcmode );
    AddToComposite( Volume, indexname, "V", atcmode ); 
    //AddToComposite( OI, indexname, "I", atcmode ); 
    //AddToComposite( Aux1, indexname, "1", atcmode ); 
    //AddToComposite( Aux2, indexname, "2", atcmode ); 
  1. apply it to Analysis
  2. Go to Backtest settings and in General - Periodicity set your preferred base time interval of the new symbol to be created via ATC.
  3. Set “Apply to:” to Current, All symbols or some Filter
  4. Click Scan and wait for “Completed…” message in Analysis Info bar
  5. Go to Symbols window - Group 253 to view the “clone(s)” been created

That is pointless exercise.
AmiBroker compresses base interval to any other interval ON THE FLY by itself, automatically.
You don’t need to do ANYTHING. Just change View->Interval for chart or “Periodicity” in the Analysis settings.

It is pointless also because of the fact that if you are using eSignal you can have multiple databases using different base interval too.