One of the important values in calculating credit score is the average age of credit line. What I am wondering is if this includes all credit lines ever opened or just currently open credit lines. For example, if I open a credit card and a couple months later decide that credit card isn't right for me so I close it will it always drag down my credit score since I had a line of credit open for only a short period of time?
When calculating average age of accounts VantageScore does not include closed accounts, whereas FICO does.
However, anecdotal assertions suggest that as long as the closed account remains on the report (typically for 10 years), age will be calculated to the present rather than to the date of closure. Thus, closing a recently opened account should not result in a persistent drag on average age.
The details of the answer to this depends on the scoring model used - average age of accounts is calculated differently in different models and versions. Some include closed accounts and some don't - even within specific model brands (i.e. FICO) the calculation changes from version to version.
It also depends on the time frame you're referencing - I'm assuming you mean "now" as in, if I close the account now, will it impact my score immediately? For models that do not include closed accounts, the impact will be immediate. But, even in models where closed accounts are included in the average age calculation, they eventually drop out - closed accounts only remain on your credit report for a set time frame, so even if there is not an immediate impact, there will be an impact some time in the future - typically 7 or 10 years - when the account finally ages off your credit report and can no longer be included.
So: short answer - The impact to average age may happen immediately, or after a number of years, but closing an account will always - eventually - impact your average age of accounts. And, counter-intuitively, depending on the model used, the impact can be greater in models that include closed accounts, because by the time they age out 10 years later, they're 10 years older when they actually drop off. Consider if you chose to close an account a month after opening it. Models which disinclude closed accounts would probably show a score increase, because you're dropping a month-old account. Models which include closed accounts would show a loss of a ten year and one month old account, ten years from now. For most people, losing a ten year old account will have a negative impact on your score.
As an important footnote, besides average age, closing a credit card account can have other impacts to your credit score. If you ever carry balances on any other credit cards, your utilization will increase (due to the loss of limit on the closed card). Also, if this was your only credit card and you close it, your credit mix will get worse. These impacts are a little more straightforward than average age of accounts.
Generally, for many people, closing a credit card account can result in some degree of negative impact, at some point - which is why typical advice is to leave credit cards open unless you have a specific reason to close them, or consider converting to a no-annual-fee product (if allowed by your issuer) if you are thinking about closing the card due to annual fees.