[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] AFL programming style questions


  • To: Dennis Brown <see3d@xxxxxxxxxxx>
  • Subject: Re: [amibroker] AFL programming style questions
  • From: Herman vandenBergen <psytek@xxxxxxxx>
  • Date: Sat, 2 Aug 2008 03:58:52 -0400

PureBytes Links

Trading Reference Links

Title: Re: [amibroker] AFL programming style questions

I have tried many styles but was never able to stick to anyone. Here are some of my preferences however i am afraid I don't have a specific style. 


I like compact listings to see the maximum number of lines at once. 

I rarely use multiple statements in one line. 

I use empty lines to space functional blocks, not to space code for visual effect.

I like to indent the curly brackets, to make function and other blocks of code stand out better

I use include files when I can to shorten listings. i frequently paste the code temporarily back in for debugging. 

If I need to store a lot of calculated variables I may write them to an include file instead of using StaticVariables or persistentvariables. I use #Pragma NoCache to get it read each time.

I use long descriptive variable names; its usually less typing and easier to read than adding long comments.

I break up lengthy calculations to give me debugging points.

I use DebugView a lot, every day.

I use three //////// rows to separate major functional sections to allow spotting them when scrolling through thousands of lines of code.

I key most static variables to prevent them from being common to multiple applications

I use persistent variables to facilitate easy start up sequences and to keep trading (IB/TWS) records

I like to see initialization blocks because conditions often change

I have folders in my Charts workspace that contain frequent used code snippets, segments, templates, etc. I edit-copy-paste from these

I often work with two editor windows, one to copy from, one current work

I Apply my include files to a separate pane/tab so I can easily open/modify include files. i use 20 tabs.

I use Chart tabs to organize work in progress and create Layouts for major code changes, or new systems.

I use revision numbers for all programs, like ProgramName-001. This creates lots of files and requires me to run Program maintenance once a week.

Once a week I search my computer for all afl files and import them into dated-folders in InfoSelect.

When assigning many variables I like to tab all the "=" signs to the same level for easier reading.

...


best regards,

herman





Friday, August 1, 2008, 9:07:31 PM, you wrote:


> Hello veteran AFL programmers,


> I am still working on developing a consistent AFL style.


> I am writing a lot of AFL functions.  I try to make as many things  

> functions as I can so that I can reuse a lot of code.  It also makes  

> it easier for the editor to find syntax errors since my main code is  

> indicator only and the syntax check pass does not see that code since

> it runs without the Chart ID.


> My trading platform is over 5000 lines of AFL (I keep adding more, and

> it keeps getting smaller...LOL).  About half of that is functions.  I

> pass a lot of data through global variables and arrays between  

> functions for the state of the system.  It was the only efficient way

> that I knew how to make code modular was to have the data common.  AFL

> is largely based on that premise already with special state variables

> and price/trade arrays.


> Right now, I have a mix of variable initializations and just global  

> declarations at the top of the formula so that I don't have to declare

> the globals in each function.  I still have a lot of global  

> declarations in some functions, but I want to finish getting rid of  

> them and just have them declared at the top with a good description of

> how they are used.


> I had it in my head that a bunch of global declarations in a  

> frequently called function would slow down the execution of the  

> function.  Am I right about that?

> I thought I could just mention the names of the input and output  

> variables in the header comments if needed for documentation.


> I am also slowly changing my comments from //  to /*  */  so that they

> are not in the execution path.


> I am starting to make my variable names longer so that they are more  

> descriptive of the data they hold.


> I have some naming conventions like FP_Name for variables that are  

> part of my Flexible Parameters system and exist outside of that module.


> I am now planning on adding GP_Name for global parameter names and  

> SP_Name for symbol specific parameter names.  In Flexible Parameters,

> I give my parameters distinct names independent of their displayed  

> labels.  Those will be more than mere convention in that they will  

> cause the parameters to be saved in a different file folder.


> What kind of naming conventions do you use that you are proud of?


> Any other unique features of your program style that you think are  

> worth copying?


> Thanks for sharing your style ideas.


> Best regards,

> Dennis



> ------------------------------------


> Please note that this group is for discussion between users only.


> To get support from AmiBroker please send an e-mail directly to 

> SUPPORT {at} amibroker.com


> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:

> http://www.amibroker.com/devlog/


> For other support material please check also:

> http://www.amibroker.com/support.html

> Yahoo! Groups Links


> <*> To visit your group on the web, go to:

>     http://groups.yahoo.com/group/amibroker/


> <*> Your email settings:

>     Individual Email | Traditional


> <*> To change settings online go to:

>     http://groups.yahoo.com/group/amibroker/join

>     (Yahoo! ID required)


> <*> To change settings via email:

>     mailto:amibroker-digest@xxxxxxxxxxxxxxx 

>     mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx


> <*> To unsubscribe from this group, send an email to:

>     amibroker-unsubscribe@xxxxxxxxxxxxxxx


> <*> Your use of Yahoo! Groups is subject to:

>     http://docs.yahoo.com/info/terms/



__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___