The demaCrossover variable we make here gets a true value when a buy signal occurred on the current bar. It holds false when such signal didn't happen. We get that value by evaluating several conditions with a cascaded if statement (a series of if statements). It looks like a lot, but let's walk through it.
The first if portion checks if the len2 and len3 input variables are both greater than 0. When they are, we assume that all three DEMA lines are configured to show on the chart. And so for the buy signal we look at two things: