Swing Highs and Swing Lows

 

Hello,

If I wanted to use swing highs and lows to determine fibonacci ratios and to set trailing stop losses from in an expert advisor, what algorithm would I use to determine these swing highs and lows?

I put a chart below indicating what I mean:

Thank You

ThemBonez

Reason: