LW Stop

I am trying to script Willstop.

For a low stop I want to find the HighestClose of the up move so far – so say H1 =Bardate()==HighestHigh(Close(), Bars=50, INCBAR=True)

Not sure Bardate makes sense but maybe.

Now I want the lowest low (lets call it L1) starting from H1 and a lookback of 3 bars not including inside bars. Once that is found I want to look at the bar before that date to see if it was an UPCLOSE; if it was, go back one more bar and use the lowestLow between the date just found and the H1 date.

Not sure how to start a LOWESTLOW() from a BARDATE.
Or maybe there is a better way to approach this.

LWStop.pdf (54.5 KB)

LWStop2.pdf (44.1 KB)