A trailing stop order is a stop order with a limit that "trails" after market price. They are normally used by traders to lock in profits of an existing position once the position PnL has gone into positive territory.
In a buy trailing stop order, limit is set at a fixed number above market ask with a "trail" amount. When market ask falls, limit will also fall ("trailing" after market ask) by the trail amount. When market ask rises, limit does not change, and the order is executed as a market order when the limit is hit.
Vice versa, in a sell trailing stop order, limit is set at a fixed number below market bid with a "trail" amount. When market bid rises, limit will also rise ("trailing" after market bid) by the trail amount. When market bid falls, limit does not change, and the order is executed as a market order when the limit is hit.
In margin trading, a trailing stop order is exactly like a market order, and the "trailing stop" has no meaning.
Let’s look at an example. A trader has bought 10 BTC at $3,000 and the price has now moved to $3,500, which means he’s currently sitting on a nice profit of $500 per BTC or $5,000. He feels the market will continue to go up but there is no guarantee so he wants to lock in his profits at $3,400 or $400 per BTC. In other words, he is willing to forgo $100 of his current $500 profit. He could do this by placing a simple stop sell at $3,400 for 10 BTC. This would allow him to keep $400 of the profits. But what if the price keeps going up? He would like his stop to also move accordingly so he can lock in higher than $400 profit and he’s still willing to forgo $100. So if price moves to $3,550, he would like his stop moved to $3,450 and so on. He could do this manually but then he would need to constantly monitor the market and manually adjust the stops, not a very feasible operation. This is where trailing stops come in. In this case, setting up a sell trailing stop with a distance of $100 would allow him to achieve just that. If price moves up, the stop adjusts keeping the $100 distance. If the price moves down, the stop does not move but it might get hit allowing him to take profits.