1. for each and every 10 mph of train speed, how far should the horn sequence trigger be placed from the crossing?
10 mph: 220-293 ft
20 mph: 440-587 ft
30 mph: 660-880 ft
40 mph: 880-1174 ft
50 mph: 1100-1320 ft
60 mph (and above): 1320 ft
This is based on current NORAC operating rules, which cover most railroads in the eastern US. Other railroads may have different rules, but I would think they'd be very similar. Specifically, this is rule 19(b)1:
Sound: - - o -
Indication:
When approaching a public highway-rail crossing at grade and at a whistle sign displaying "W," "W/MX," or other specified aspect, with the engine in front, start whistle signal at least 15 seconds but not more than 20 seconds before occupying the crossing. The signal must be pro-longed or repeated until the engine occupies the crossing. For multiple crossings, the signal must be prolonged or repeated until the last crossing is occupied.
For trains and engines exceeding 60 MPH, the whistle signal must not be started more than 1/4 mile in advance of the public grade crossing, even if the advance warning provided by the locomotive horn will be less than15 seconds in duration.
When a train or engine is stopped at a location such that it will take less than 15 seconds for the movement to occupy a public grade crossing, the whistle signal may be sounded for less than 15 seconds provided:
(a) The public grade crossing is equipped with automatic flashing lights and gates and the gates are fully lowered;
or
(b) There are no conflicting highway movements approaching the public grade crossing.
EXCEPTION: This warning must not be sounded at a whistle sign indicating "W/R" or in areas otherwise designated as Quiet Zones, except in an emergency.
The rule specifies 10-15 seconds rather than distance; I just converted that to feet using this formula: feet = seconds x mph x 1.467.
Here's a link to the full rulebook:
https://www.hubdiv.org/docs/signaling/NORAC.pdf
Back in the old days, rules were not as specific. I just checked a Pennsylvania Railroad rulebook from 1950 for example, and it only states that the horn/whistle sequence should be sounded at crossings, and should be repeated or prolonged until the locomotive enters the crossing, it seems to leave the exact distance and timing to the engineer's judgement.
2. for each and every 10 mph of train speed, how far should the crossing gate trigger be from the crossing?
I really don't know. I have noticed that the gates almost always go down before the horn is heard though, usually about 10 seconds before, so if you add 50% to the numbers I gave above you would probably be pretty close.
3. should there be some kind of crash barrier along side the track if it's close to a cliff?
As whitepass mentioned, a crash barrier wouldn't be able to stop a train, so they don't have those. Some railroads do use guardrails in such places though (as well as on bridges) to help the train stay on the track at least if it derails, and not go over the edge:
https://en.wikipedia.org/wiki/Guard_rail_(rail)
Hope this helps!