If Avast detects (and handle acordingly) or not depends on the settings you as user make.
If you setup Avast correctly, than Avast will detect and prevent trojans from running and even from comming them on your system.
To clean your system, click on the link in my signature and follow the instructions in the malware removal section