Hello,

I'm a new user of Quantconnect, Python, and programming more generally, so I think this is a pretty fundamental point that i'm missing about control flow. I've taken courses in Python which have noted that the code will be executed top to bottom within the script. I'm struggling to understand how I should be structuring my code such that all functions are called after they are defined. 

I've come across numerous examples in QC tutorials where a function is (or seems to be, to my eye) called before it is defined. One such example might be in a line like:

self.AddUniverse(self.CoarseFilter, self.FineFilter)

Which would be placed in the Initialize method, and then “CourseFilter” and “FineFilter” are defined later in the body of code. Would someone please offer an explanation to this?

On a related point, how can I work out which parts of my algorithm can ‘see’ data which has been imported by, say, a History request?

Best,Luke