The military salute, made with right hand to head of a soldier, seems to be a European tradition, however it is adopted by many armies in the world.

What are origins of this gesture?

I came across a theory that it comes from a medieval knights' gesture of opening the visor of their helmets. According to this source the purpose was to

reveal his identity as a courtesy on the approach of a superior.

But I'm not entirely sure this is correct, as the identity of a knight was clearly known from the coat of arms painted on his shield. This article says the reason could be that an inferior soldier (i.e. not a knight) opened his visor to his superior to identify himself, but

the modern form of salute is not recorded before the early 18th century.

(According to this Wikipedia article, the explanation that connects the gesture with medieval knights is somewhat questionable.)

Further, we read:

The salute probably developed in response to a change in military headgear. After metal helmets fell out of favour, soldiers wore hats similar to those of civilians. Like civilians they raised their hats when greeting a superior.

By 1700 grenadiers were wearing tall, conical hats held in place with secure chinstraps that were difficult to raise in greeting. The men began to merely touch their hats as if intending to raise them. Soon other soldiers adopted the shako, busby or bearskin, all of which were held in place by a chinstrap. They, too, stopped raising the hat and instead merely touched its brim. This action was formalised as the salute in European armies by about 1780, and from them spread to the rest of the world.

This article is quite interesting, however not citing any sources and looks a bit like popular science, but for me is acceptable.

There could be a connection to ancient Roman salute and greeting to show empty (ie. without weapon) hands, which we probably still use in a handshake gesture.

This confirms yet another source, saying that

One theory is that it came from Roman soldiers' shading their eyes from the intense light that was pretended to shine from the eyes of their superiors.

(how do we know it was from Romans not eg. Greeks?)

Further

The most widely accepted theory is that it evolved from the practice of men raising their hats in the presence of officers. Tipping one's hat on meeting a social superior was the normal civilian sign of respect at the time. [emphasis mine]

I disagree it's most widely accepted, as shown earlier.

At first I wanted to ask "what are the origins of saluting", but it seems there is no good or sure answer for this. So my question is: What is the earliest known account of the modern military salute? I'm not asking when it was introduced, but for the earliest known account. As written above, the early 18th century would be the date, but is there any more information? Or maybe there is an earlier historical source?