Style guide AFL

Good morning to all:
I am starting to program AFL and I wanted to know if there is any style guide like the PEP 8 of python and if there is any naming convention for the variables and indicators.
A cordial greeting

@Jhony5 You should start from reading this thread:


https://www.amibroker.com/guide/AFL.html

Thank you @Milosz, for your quick response, that's great!
I already read me the links you shared.
I realize that some names of indicators are in Capital, others in minuscule. I'd just like to know if it's better UpperCamelCase or lowerCamelCase. How to differentiate well between variables and indicators so that the code can be read better.
Thanks again

I prefer Upper Camel Case, but it is up to you, because AFL is not case sensitive.

obraz :wink:

I quote from: https://www.amibroker.com/guide/a_language.html

AFL recognizes five classes of tokens: identifiers, constants, string-literals, operators, punctuators (also known as separators).

Identifiers are arbitrary names of any length given to functions and variables. Identifiers can contain the letters (a-z, A-Z), the underscore character ("_"), and the digits (0-9). The first character must be a letter. AFL identifiers are NOT case sensitive.

But I'm not a professional coder, so maybe other users step in and share their view about naming conventions.


On the other hand AFL Formula Editor uses Syntax highlighting which helps to differentiate between different language elements:

AmiBroker's AFL editor features user-definable syntax highlighting that automatically applies user-defined colors and styles to different language elements like functions and reserved variable names, strings, numbers, comments, etc. This feature greatly simplifies code writing. You can modify coloring scheme in Preferences window.

https://www.amibroker.com/guide/w_afledit.html

... and additionally check out AFL Editor's Prettify selection feature.

Regards

4 Likes

@Jhony5 there is no universal AFL coding standard that I am aware of. I think the most important concerns are consistency and readability, which is true for any language that you program in. For my own coding, I use naming conventions that are similar to other languages that I work in:

  • Constants: ALL_CAPS
  • Variables: lowerCamelCase
  • Functions: UpperCamelCase()

For code formatting, you may wish to consider what code looks like after using the Edit / Prettify Selection option within the AFL formula editor. This will raise the age-old debate of whether it's better to indent with tabs or with spaces. I'm a tab man myself, and Prettify uses spaces. I'm so accustomed to formatting my code as I enter it that I never use this feature anyway, but it's great for those who are not yet experienced coders.

7 Likes

@mradtke I like your convention. I will use it from now on in my code so that it can be read better.
Thank you very much!