How to make afl password protected , so no changes can be made to the afl code?

hi all
how can i lock the afl???

thanks in advance

Tomasz has already answered similar question here:

Locking is not the same as encrypting.

Locking is not intended to protect the formula from viewing, but to protect
it from accidental edits. If you are an active developer you may test
thousands of programs and there will be some that seem to have potential in
one way or another that you want to keep and protect for later analysis. In
those cases it is handy to be able to lock a formula to protect it from
accidental edits or other users errors. Nothing worse in a developer’s life
than lose a formula that gives exceptional results and then have to spend a
lot of time trying to get it back to how it worked originally, and fail.

If this is why you are inquiring about locking then you have two tools to
help out: Undo and the AA Report Explorer. However that may still take some
time depending on what you are looking for, sometimes it’s a stat and other
time it may be a plot, and how far back you have to undo. You may have to
run many Backtests and/or load many formulas from the AA Report Explorer.

A locking feature that locks the formula from edits but permits copying
would have saved time in those situations.

Best regards,

Herman, such “locking” feature is part of file system and is called “read-only”. You can mark ANY file as “read-only” and OS (file system) won’t allow you to save modified file if it is read-only. That works for ALL files, not only .AFL.


Thank you Tomasz, I wasn’t aware of that… I googled setting/clearing the
read-only file attribute programmatically and found this:

File.SetAttributes(filePath, File.GetAttributes(filePath) &

Would this be something we can invoke using shellexecute? The idea is to
create a trigger (Button or Param) that gets the formula path and saves a
read only copy in a separate folder - without interrupting the editing
process. That would be so neat!


1 Like

Once a month, I will dump all the Amibroker databases and formulas to a 128GB thumb drive. It protects against hard disk failure too.

1 Like

yes exactly , my reason is to lock the afl is to avoid accidents and common errors , as i am having a team of traders under me who cannot code or understand the afl, and if they by mistake do any code changes, than i will have to keep a track of the changes.
to avoid such a scenerio i was thinking of applying a lock.

any ways if dll can solve this purpose , i would like to understand how to convert the alf in to dll file.
and yes i am very much satisfied with the read only solution too…

thanks in advance

Use a Zip/Compression library to zip them up with password protection. A bit of extra work but might suffice.