First off, EntityCollided is actually not the right command. I just looked it up in the manual because those parameters don't look right, and that's when I noticed the command you want is the similar sounding but different CollisionEntity. To use that, you'll first need to use CountCollisions to detect if a collision happened; then use the collsion ID returned by that command to check if CollisionEntity is the one you are after.
Second, the placement of that code matters, of course. Specifically, it needs to be in the main loop after UpdateWorld, since that is when collision detection happens.
Second, the placement of that code matters, of course. Specifically, it needs to be in the main loop after UpdateWorld, since that is when collision detection happens.