hello,
I am an AFL code learner.
My question is related to objects in Amibroker.
I used/use an update system for my database, based on Amibroker objects
** **
specifically .import ....????.format
AB = new ActiveXObject( "Broker.Application" )
AB.LoadDatabase("C:\\Program Files\\AmiBroker\\myBBDD");
// AAII_SENTIMENT
AB.Import(0, MyPath + “ \\MACROUSA\\AAII_SENTIMENT.csv", "AAIISENTIMENT.format");
// CURVASTIPOSFED
AB.Import(0,MyPath + “\\MACROUSA\\CURVASTIPOSFED.csv", "CURVASTIPOSFED.format");
// TIPOS
AB.Import(0,MyPath + “\\MACROUSA\\TIPOS.csv", "TIPOS.format");
// TREASURYYIELD
AB.Import(0,MyPath + “\\MACROUSA\\TREASURYYIELD.csv", "TREASURYYIELD.format");
// USLEADINGINDICATOR
AB.Import(0,MyPath + “\\MACROUSA\\USLEADINGINDICATOR.csv", "USLEADINGINDICATOR.format");
AB.SaveDatabase();
and run an updater on .APX files.
`AB = new ActiveXObject("Broker.Application");
AB.LoadDatabase("C:\\Program Files\\AmiBroker\\myBBDD")
//
var Path = "C:\\Program Files\\AmiBroker\\Formulas\\APX\\"; // Load Path to APX directory
//
var APXList = ["ibex35.apx", "nasdaq100.apx", "russell2000.apx", "SP500.apx"];
var LongArr = APXList.length;
//
for (i = 0; i < LongArr; i++) {
// Runs for the number of items you have el Array
fch = APXList[ I ]; // Load the file to use, from the list
Analyzes( fch); // Call the scan function to explore the APX
}
….
….
function Analyzes( FichAPX ) {
try {
PathYFich = Path + FichAPX; // Add to the path the name of the file to be processed
NewA = AB.AnalysisDocs.Open( PathYFich ); // Creates the NewA object, New Analysis,
// from Object AB (amiBroker), with its object
// AnalysisDocs and the Open property (open) the passed file
if ( NewA ){ // Asks if it exists so that there is no error, if you find it
NewA.Run( 1 ); // Runs the scan of the entire object (1),
while ( NewA.IsBusy ) WScript.Sleep( 500 ); // While AmiBroker is busy waiting for 0.5sg,
NewA.Close(); // Closes the object of the new analysis
AB.SaveDatabase(); // Save the database you have in use, the one loaded at the start
}
catch (err) {
_TRACE ( "Ends_Err."+FichAPX );
}
}
`
I read the document https://www.amibroker.com/guide/objects.html and I have been warned of the danger; but if it works in javascript, why doesn`t it work well in AFL?. In the objects use the examples that are in the doc, with javascript and they both work well if I run them from DOS.
I have recently tried to pass these processes to .afl formula and the import process has worked without problems.
specifically .import ....????.format // work well
objAB = CreateObject("Broker.Application");
//objAB.LoadDatabase("C:\\Program Files\\AmiBroker\\miBBDD"); // It isn't nesesary but BBDD is in use
// AAII_SENTIMENT
objAB.Import(0, MyPath +"MACROUSA\\AAII_SENTIMENT.csv", "AAII_SENTIMENT.format");
// CURVASTIPOSFED
objAB.Import(0, MyPath +"MACROUSA\\CURVASTIPOSFED.csv", "CURVASTIPOSFED.format");
// TIPOS
objAB.Import(0, MyPath + "MACROUSA\\TIPOS.csv", "TIPOS.format");
// TREASURYYIELD
objAB.Import(0, MyPath + "MACROUSA\\TREASURYYIELD.csv", "TREASURYYIELD.format");
// USLEADINGINDICATOR
objAB.Import(0, MyPath + "MACROUSA\\USLEADINGINDICATOR.csv", "USLEADINGINDICATOR.format");
objAB.SaveDatabase();
and run an updater on .APX files
`Path = "C:\\Program Files\\AmiBroker\\Formulas\\APX\\";
DataPath = "C:\\Program Files\\AmiBroker\\External Data\\";
APXList = LeeFichero(DataPath + "FichComposyteAPX.txt"); // Load the list from an external file
// list Separate by “,”
LongArr = StrCount(APXList,",")+1;
for (i = 0; i < LongArr ; i++ ){
Fich = StrExtract( APXList, i );
FilePath = Path + Fich; // add de path to file process
// AB is an open database ,created at the beginning
// AB = CreateObject("Broker.Application");
ObjTrabj = AB.AnalysisDocs.Open( FilePath ); // Creates the work object, New Analysis,
// from Object AB (amiBroker), with its object
// AnalysisDocs and the Open property (open) the passed file
if ( ObjTrabj ){ // Asks if it exists so that there is no error, if you find it
ObjTrabj.Run( 1 ); // Executes the scan on the object (1)
while ( ObjTrabj.IsBusy ) ThreadSleep( 100 ); // While AmiBroker is busy waiting for 0.1sg,
// and repeat this process until the scan is complete
ObjTrabj.Close(); // Closes the object of the new analysis
}
AB.SaveDatabase();
}
`
but the .APX process gives me an error which I don't understand, because the class exists and should be able to be derived by model hierarchy, and even defines it in note(2) of the doc.
Can you help me find more documentation and examples where to learn about these objects?
What object can I use to derive the .AnalysisDocs., its methods and properties?
Thanks for your help.
All the best