During my testing, I have noticed that when I use the Auto-Repeat option for Explore, the time from the start of one exploration to the start of the next exploration equates to the Auto-repeat time interval chosen in the settings + the time taken to run an exploration.
What I would like to be able to do, is run an exploration every 5 minutes that starts 2 seconds after the last 5 minute bar has closed and I don't want the length of the exploration itself to affect when the next exploration runs. I.e. It keeps starting a new exploration 2 seconds after the last 5 minute bar has closed.
Is it possible to set the auto-repeat option to start x seconds from the close of a specific time interval bar instead within the AFL script itself or in any other way?
Interesting, I was not aware of Batch. However it does not seem to support scheduling more fine grained than hourly. Ideally I would like to perform a scan every minute. I will have a go at the OLE interface and see if I can drive the scan that way.
// Does an amibroker scan every minute, on the minute (well 2 secs after).
// run with cscript.exe
// See https://www.amibroker.com/guide/objects.html for doc on Amibroker OLE interface.
var analDocPath = "c:\\dev\\ami\\autotrader\\autotrader-analysis1.apx"; // created by saving analysis file (file -> Save AS) in Amibroker
try
{
var AB = new ActiveXObject( "Broker.Application" );
var analDoc = AB.AnalysisDocs.Open( analDocPath );
log("starting")
while(true)
{
var ms = getMsToNext(60);
WScript.Sleep(ms+2000);
log("scan")
analDoc.Run(0); // scan
}
}
catch(e)
{
log( "Exception: " + e.message ); // display error that may occur
}
function log(msg)
{
WScript.Echo(getDateTimeStr() + " " + msg);
}
function getMsToNext(sec)
{
var now = new Date();
var r = 0;
var ms = now.getSeconds()*1000 + now.getMilliseconds() ;
if (ms < sec * 1000)
r = sec*1000 - ms;
else
r = 60*1000 - ms + sec*1000;
return r;
}
function getDateTimeStr()
{
var dt = new Date();
return pad(dt.getDate()) + "/" + pad(dt.getMonth()+1) + "/" + dt.getFullYear() + " " +
pad(dt.getHours()) + ":" + pad(dt.getMinutes()) + ":" + pad(dt.getSeconds()) +
"." + pad(dt.getMilliseconds(),3);
}
function pad(num, size)
{
if (!size) size = 2;
var s = num+"";
while (s.length < size) s = "0" + s;
return s;
}