Two stay ahead of protoss you usually need to 1 up the amount of bases they have and try to delay the third as much as possible. to do this you can send lings to get the cancel or send a small portion of your army to do it. If you are losing to dark templars lately because you don't have detection is build 2 overseers for your army and 1 for your bases. To stop the early push from protoss you might have to delay the third base drones and build some units to defend from it. Roaches and Hydras will work but if you want to do lings instead of hydras it works to. If you see an early stargate built your opponent is more likely to try and send out an oracle if this happpens make sure you have your overlords spaced out at your base to detect it before it hits your mineral line. To stop protoss from warping units in your base you might want to leave some units at home to defend it.
Here's a good build vs a standard protoss (either gate expand, stargate play, even 4gate/cannon cheese) basically it relies on early speed to deny proxy pylons and gateway pushes and hydras because they're good against gateway units, immortals and can shoot over FF's
15 Hatch (send drone to check for cannons, OL doesn't arrive in time)
@100% pool, queens x 2, lings x 1 (1 pair)
@100 Gas ling speed, pull 2 drones
30 Hatch (can be earlier but this lines up better)
42 Queen (@ natutal)
***Pump lings as needed for pressure against protoss timings
***Sac OL around 6-7min and get warren in you're nervous
@100 Gas Lair/ Gas / 2 more back in gas
@7min Gas x 2
@100% lair Hydra den
***Get hydra ups as affordable!
@10:45 Gas x 2, evo x 1, warren if you didn't get it already
***slowly transition into roach hydra
11min infest. pit
12min hive, 4th etc.
Pretty sure Day9 did a daily on this, I think it was one about TLO IIRC
For protoss its really standard scout during the early stages to determine what kind of opener wether hes going for an all in or not. Then late game try and stay ahead in terms of economy and deny his expansions as much as possible and once u scout go for the counter to his build.