There actually has been a standard rulebook since before 1899 that defined the use of markers. But each railroad could and did make changes to suit their own preferences.
The most common standard was for red to show to the rear whenever the train was occupying the main track. If a train was clear of the main track and switches were properly lined back, the markers were turned to show green (or yellow on some RRs) to the rear. Basically, red meant a probable rear ender - much more common than head-ons, green/yellow meant the main was clear. One lines with double track, it was common to show red on one side and green/yellow on the other if the train was running against the current of traffic.