What is the Credit-to-GDP gap exactly? I have been hearing a lot about this metric in relation to rising fears of a Chinese financial crisis. I am wondering, what exactly does this mean? I am told it refers to the difference between current credit-to-GDP ratios and long-term trends but I don't fully understand what that would mean. What would be a nice little equation for it? I have looked at some charts and I am seeing that the US has a negative Credit-to-GDP gap, how can it be negative? I just want to know what the inputs into calculating that would be so I can understand for myself what these things signify.
Thanks.
The Credit-to-GDP, say  ratio measures the relative size of the outstanding debt of non-financial private sector, say $D_{p,t}$ with respect to (yearly) Gross Domestic Product, say $Y_t$

$$\text{Credit-to-GDP ratio} =\frac { D_{p,t}}{Y_t}$$

Note that GDP should be measured in nominal terms here, since so is debt. It is a metric related to how much burden WE have placed on our future from our current decisions and activities.

The "Credit-to-GDP" gap is, as the OP notes, "the difference of the Credit-to-GDP ratio from its trend". How do we extract that? 

Look for example at the, informative with data and literature, page of the Bank for International Settlements. If you hit the "data" link, you will see that what they do is
a) calculate the Credit-to-GDP ratio (per quarter but always using past-12-months GDP in the denominator), and then decompose the obtained time series by using the HP filter.

The Credit-to-GDP gap is what it remains if from the actual "Credit-to-GDP ratio" series we subtract the (non-linear) trend as calculated by the HP filter. One can understand why then this "gap" can be negative: we are currently below the trend. Finally note that the Credit-to-GDP gap is also measured in GDP percentage units. But sometimes it may be reported as percentage deviation from the trend (i.e. "we are 30% above trend" does not mean that we are "30 percentage points of GDP above trend"). So read carefully any source.

The question is: why use the "gap" and not the ratio itself?  

Because we are accepting that the trend likely reflects a sustainable evolution of the economy over time (sustainable by the very ongoing existence of said economy), while the "gap" reflects short-term tendencies that may not be sustainable and may lead to crises if left unchecked and un-managed. 

A higher positive gap means that the private sector borrows at a level that is perhaps "not justified" by the current output-producing abilities of the economy. Banks may tend to experience abnormally high rates of loan defaults etc, which can lead to a banking crisis. 

A negative gap supposedly implies that there is a "safe" amount of additional borrowing that could be done currently (for consumption or investment purposes), and we are leaving it "unexploited".  

But never read too much on a single metric, economic systems are too complex.