I'm updating AFL files on the fly with Python during batch runs, and need to generate .apx files that match what AmiBroker expects internally. I’ve tried doing this through OLE, but it only works with the old Analysis window and saves in a binary format that batch mode won’t accept.
The most reliable approach so far has been using shortcuts to load/save via the UI in a separate EXE, but that’s fragile. The main issue is replicating the exact parsing AmiBroker does when embedding AFL into the <FormulaContent> block — even small differences cause the “formula is different” error.
Has anyone figured out the exact encoding or formatting rules AmiBroker uses when saving APX files from the UI?
Thanks for the input! The encoding itself (UTF-8, UTF-16, etc.) doesn’t seem to be the main issue—my script can read and write APX files fine. The challenge is replicating AmiBroker’s internal AFL-to-APX formatting rules, like escaping < to <, doubling backslashes (but not in comments), and preserving quotes exactly. I’ve managed to match the output a few times, but every time the AFL code changes slightly, some new edge case breaks the formatting again. If there were a way to export the fully encoded APX directly from AmiBroker, or a library that mimics its exact behavior, it would save a ton of trial and error.
Thank you! That fixed it — I'm no longer getting the 'formula changed' warning. I had seen that before but misread it as meaning it keeps the version stored in the APX rather than the AFL itself.