Incorrect interval, was Missing bars in AFL

Hi everyone,

I'm relatively new to AmiBroker and I'm having a problem with AFL.

For the default database AmiBroker given, I can get all bars' information quite easily by looping over every possible arrays with a length of BarCount.

However, when I try to use another database, I can view the price normally and see all the possible data but when I try to loop over every arrays, the data doesn't seem to be there. For example, I can view the price at July 25th 12:35:27 and July 25th 12:37:03 in the main viewing window but in the AFL, I can only access a bar at July 25th 00:00:00 only. Besides that, other pieces of data seems to be a whole day and I can't get any more detail than a day. I basically want to export all possible data onto a csv file but I don't think that's important.

Any help would be appreciated.

You don't show the code that you used. It is hard to guess what your setup is without having any details. If you need help, make it easy for person who wants to help to
help you and reduce guessing games.

So without any details and any information the only guess is that your code is subject to QuickAFL read this: http://www.amibroker.com/kb/2008/07/03/quickafl/ to learn what QuickAFL is, how it works and how to control it.

If not, first check that the data are actually there using Symbol->Quote Editor.

1 Like

Sorry, I will describe it more.

So this is the code. It is supposed to export csv files to a particular folder that will be used by another app that I'm writing.

fh = fopen("C:/Users/Lenovo-1/AppData/Roaming/BrokerNotifier/" + Name() + ".csv", "w" );
if( fh ) {
    TimeFrameRestore();
    //fputs("Symbol, Date, Time, Open, High, Low, Close, OpenInt, Volume, RSI, MACD, Signal\n", fh );
    dn = DateNum();
    tn = TimeNum();
    mRSI = RSI(15);
    mMACD = MACD();
    mSignal = Signal();
    mStocha = StochD();

    for( i = 0; i < BarCount; i++ ) {
        Line = Name() + StrFormat(", %06.0f, %06.0f, %g, %g, %g, %g, %g, %f, %f, %f, %f, %f\n", 
                                      dn[ i ] % 1000000,                                    
                                              tn[ i ],                                      
                                                      Open[ i ],                            
                                                          High[ i ],                                  
                                                              Low[ i ],                             
                                                                  Close[ i ],                        
                                                                      OpenInt[ i ],                  
                                                                          Volume[ i ],               
                                                                              mRSI[i],                 
                                                                                  mMACD[i],            
                                                                                      mSignal[i],    
                                                                                          mStocha[i]); 
        fputs( Line, fh );
    }
    fclose( fh );
}
Buy = Sell = 0; // for scan
Filter = Status("lastbarinrange");
AddTextColumn("Export done", "Status");

For the default database everyone gets when first installed AmiBroker, a part of the csv file looks like this:
AA, 100629, 000000, 10.5103, 10.5103, 10.0414, 10.1, 0, 32381600.000000, 35.890625, -0.180202, -10000000000.000000, 34.977886
AA, 100630, 000000, 10.1427, 10.3088, 9.78114, 9.83, 0, 34460400.000000, 33.281643, -0.248623, -10000000000.000000, 22.094801
AA, 100701, 000000, 9.86886, 10.0252, 9.58549, 9.82, 0, 32207500.000000, 33.185909, -0.300194, -10000000000.000000, 12.307634
AA, 100702, 000000, 9.94586, 9.94586, 9.65276, 9.77, 0, 15494600.000000, 32.682320, -0.341166, -10000000000.000000, 6.982340
AA, 100706, 000000, 10.1266, 10.1559, 9.87248, 9.98, 0, 29444200.000000, 36.985424, -0.352627, -0.249473, 8.116707
AA, 100707, 000000, 10.0071, 10.31, 9.96796, 10.31, 0, 21760700.000000, 43.108387, -0.331262, -0.265831, 12.757944
AA, 100708, 000000, 10.47, 10.4993, 10.2258, 10.47, 0, 21015600.000000, 45.842087, -0.297986, -0.272262, 20.300745
AA, 100709, 000000, 10.4946, 10.7193, 10.4262, 10.69, 0, 21049500.000000, 49.422432, -0.250968, -0.268003, 29.661442
AA, 100712, 000000, 10.747, 10.747, 10.4344, 10.62, 0, 39103500.000000, 48.333134, -0.216855, -0.257774, 38.955231
AA, 100713, 000000, 11.0627, 11.0823, 10.623, 10.75, 0, 58563100.000000, 50.503857, -0.177287, -0.241676, 48.224613

Sometimes some of the values is -10000000000.000000 which I interpret as having no data.

VCB, 180723, 000000, 56.700001, 58.400002, 56.599998, 56.599998, 0, 2579870.000000, -10000000000.000000, -10000000000.000000, -10000000000.000000
VCB, 180724, 000000, 57.000000, 57.400002, 56.000000, 57.000000, 0, 1671100.000000, -10000000000.000000, -10000000000.000000, -10000000000.000000
VCB, 180725, 000000, 57.299999, 57.400002, 55.299999, 55.299999, 0, 1257900.000000, -10000000000.000000, -10000000000.000000, -10000000000.000000

The above is an entire csv file from this datasource: https://datafeed.vndirect.com.vn/. They allow you to use their product free for the first 5 days so you can try them out if you want.

So as you can see, although it seems that the datasource is fine, I can view the graphs normally but when it came to the AFL portion, it doesn't give any more detail than a single value per day.

Thanks, although I haven't enabled QuickAFL in the first place, I figured out anyway.

For everyone else who is asking the same question, in the automatic analysis window there is a settings button which will open up the "Backtester settings". Because I set my periodicity to Daily, it cause the problem above. Switching it to 1 minute fixes everything.