Puzzling _TRACE output from Repeating Exploration during Bar Replay

I'm trying to run a Batch every 5 seconds via a repeating Exploration. While trying to achieve that goal, I realized that my 5sec repeating Exploration seemed to be skipping some 5 second intervals. To investigate what I might be doing wrong, I came up with a simplified test with a TRACE within the repeating Exploration and I'm leaving out the Batch run.

Win 10 64 bit
CPU = i7-8700 3.2 GHz
RAM = 16 GB
Amibroker version = 6.30.5 64 bit
Database: local database; 5 second interval

I have my Win 10 anti-virus set to ignore the Amibroker installation folder and the folder where I keep my Amibroker databases.

Analysis / Exploration Periodicity = 5 seconds

Here is the simplified AFL I'm running as a repeating 5 second Exploration. In this example I'm not bothering to run a Batch from the repeating Exploration. This example is only meant to show that the TRACE output shows some skipped 5 second intervals.

folder  = "D:\\Amibroker\\Amibroker-Mikes-AFL\\";
file = folder + "test-batch.abb" ;

// run once code here
if( Status( "stocknum" ) == 0 )
    _TRACE( "# Run batch at timeNum = " + TimeNum() + " \n" );
    // ShellExecute( "runbatch", file, "" ); // not running Batch for this test

See the TRACE output below from the AFL formula above. Basically, I start Bar Replay running and then start the repeating Exploration. Given that my Exploration repeats every 5 seconds, I expected to see the TimeNum of each new row increment by 5 seconds; however, as you can see below, TimeNum 93235 jumps to 93245. In the course of 5 minutes I might see 1 to 3 skipped 5sec intervals. The results vary from test-to-test.


In the example above, 93240 is missing, but in another run of the same test, 93240 was not missing (but others were missing).

One other thing might be worth mentioning...
The first thing I do after loading the database and the APX file, is I open Bar Replay and I set the start time to 10/20/2020 3:59:40. I then start Bar Replay running. When Bar Replay reaches 10/20/2020 3:59:50 I sometimes start the repeating Exploration immediately , and other times I might wait 2, 3 or 4 seconds after Bar Replay hits the10/20/2020 3:59:50 point before I start the Exploration. In other words, I vary the point at which I start the repeating Exploration; however, I'm typically running it at some point between 10/20/2020 3:59:50 and 10/20/2020 3:59:55 in the Bar Replay timeline.. Varying the point at which I start the repeating Exploration seems to vary the time at which 5 second intervals will be missed.

Can somebody explain what I'm doing wrong? Can somebody replicate this?

Due to the challenges I was having with Batch, I decided to kick off my APX project using jScript / OLE instead of using repeating Explorations and Batch files. As a reminder, the ultimate goal was to run repeating Explorations with Bar Replay. My expectation was that I could constrain Exploration signals and Backtest trades to a 15 minute window for testing, and that the results of Bar Replay backtest should match the results of running a full backtest (no bar replay) constrained to the same 15 minutes... in this case AFL rules constrained signals/trades to TimeNum between 093000 and 094500.

When using jScript / OLE for the first time, I didn't get the (apparently random) skipping timestamp intervals. With that promising result, I substituted a larger AFL codebase and continued testing. Unfortunately, the random time interval skips reappeared. While running a full backtest seemed to return the same result through multiple tests, the Bar Replay trades varied and would typically not match the result of a full backtest.

Then... as I opened my database to run more tests, my Watchlist was gone. Instead of reloading a backup copy of the database, I decided to build a new database. After loading the new database, I no longer had problems with missing/skipping intervals and Bar Replay backtest results now match my full backtest results.

My next step was to nix the jScript / OLE approach and try using repeating Explorations and Batch again. That worked fine also. Both approaches returned the same results with Bar Replay backtesting and also with full backtesting without bar replay.

I'm going to guess that my original test database had some corruption. Multiple tests seem fine with the new database.

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