Why use section begin?

#1
Why do people use section begin in their code? So far as I can tell, it does nothing but make it more difficult to remove it to the chart.
 

amitrandive

Well-Known Member
#2
Why do people use section begin in their code? So far as I can tell, it does nothing but make it more difficult to remove it to the chart.
It marks the begin and end of a drag-drop section.
Also useful when we have different indicators in one AFL,easy to distinguish and better organized code writing.

If not comfortable , you can use QuickAFL

https://www.amibroker.com/kb/2008/07/03/quickafl/
 
Last edited:

trash

Well-Known Member
#3
So far as I can tell, it does nothing but make it more difficult to remove it to the chart.
So far as I can tell, you prove once again not having the slightest clue of what you are talking about.

It's not Section_Begin and Section_End which make it difficult but it is wrong usage of those and other functions in amateurish codes doing it. So long story short it is the "programmer" but not the functions who make a code good or awful.

And as we all know by experience your ones are still part of latter category (which doesn't mean that it may not change to the better in the future).

??
 

mastermind007

Well-Known Member
#4
Why do people use section begin in their code? So far as I can tell, it does nothing but make it more difficult to remove it to the chart.
Contrary to that, Sections make it infinitely easier to add and remove portions of the code from the chart provided you take pains to understand it.

Besides that, it is organizational perspective.

You can remove all sections and choose to use unorganized AFL. No one is stopping you from that.

@amitrandive QuickAFL and naming sections are not related to one another.
 

yusi

Well-Known Member
#5
Why do people use section begin in their code? So far as I can tell, it does nothing but make it more difficult to remove it to the chart.
Besides what has already been mentioned, one visible benefit is that user inputs within a section are grouped together in the Parameter window. For example, in the Price (all in one) afl, check how the Price / Period / Color / Style inputs group for MA, Mid MA, Long MA, etc.

If you did not use sections, how would you distinguish multiple uses of ParamColor( "Color", colorCycle ) ?
 
#6
Contrary to that, Sections make it infinitely easier to add and remove portions of the code from the chart provided you take pains to understand it.
I just use comments to label different sections. As the only noticeable difference in practical use I can see is the 'delete indicator' menu option.

If you did not use sections, how would you distinguish multiple uses of ParamColor( "Color", colorCycle ) ?
I do paramcolor ( "Indicator Y Color", colorred ) or so.

I was just wondering if it had a specific use, besides a fancier way of commenting. I was trying to figure out if you could physically separate the price chart from the indicator with it, but it doesn't seem you can do it like that.

Thanks guys.
 

yusi

Well-Known Member
#7
@Hedron: fair enough. As you know, using sections is not compulsory, but is preferable. You could avoid using them using the techniques that you mention. I did think along similar lines when namespace was introduced in many coding languages -- why add another level of hierarchy and complication when enough code had already been written without it.

Over time, the opinion may change between fanciful, useful, good-practice, how-could-i-live-without-it phases. Let me know when you transit such states.