I think he was a Charles II or James II bastard grandgrandson.
Neither Charles II nor James II allowed their illegitimate children to use the Stuart surname, which makes it highly unlikely that Baron Friedrich Stuart was a descendant of either of them. Further, their illegitimate children (and their descendants) habitually named their own children after famous Stuarts. They regularly named boys Charles, James, or William (or a combination thereof i.e. Charles James Fox) while girls were usually named Charlotte, Mary, Anne, Henrietta Maria, or (poor things) Jemima. Friedrich (or Frederick) was not a Stuart name. I believe it came into fashion in England after George II’s eldest son Frederick, Prince of Wales, (Poor Fred) arrived in London and delighted society by fighting incessantly with his parents. Your Baron might have been named after Poor Fred but the fact that he used the German spelling makes it more likely that he was named after a powerful patron in Germany.
Your Baron may well have had ties to the royal branch of the House of Stuart. Many Scots made a living as mercenaries during the frequent wars that took place in Germany during the seventeenth and eighteenth centuries. Your Baron might have been a descendant of a Stuart soldier of fortune who won a title and perhaps an estate from a grateful employer and settled down permanently in Germany as a result. It's quite possible that that employer might have been one of the Dukes of Courland. James I and VI was the godfather of James Ketler, Duke of Courland, who was very proud of that fact. A friendly relationship was maintained between the two courts until the Restoration of Charles II, when the relationship broke down because Charles could not repay large sums of money that his late father had borrowed from the Duke. Perhaps King James or the first King Charles sent a young Stuart kinsman to make his fortune at the court of Courland during the years when the courts got along well. Without more information, it's difficult to speculate.
Hope this helps...