You are not forced to pay for a digital signature, but then you have more hoops to jump through.
As you have seen avast scans all files not just looking up whitelists. For each new program you create it is the first time in the wild so to speak so there will be little history of other avast users having run it. You never said what avast alert was given (?), so I can't really offer any detailed advice on why the alert may have occurred.
If when compiled, you can run your program and see if Avast alerts on it and what alert message given, etc. You can also set up your Avast Settings on what to do when a detection happens (Deletion shouldn't be a first option). I have mine set to ASK, or you can have it sent to the virus chest, from here it can also be sent to Avast as a possible false positive.
Or you could submit it as a false positive detection - Reporting Possible False Positive File or Website -
https://www.avast.com/false-positive-file-form.php.
Avast is in the business of protecting its users, whilst also trying to help software developers.