pseudo code to MQL4

 
I need assistance taking the following pseudo code and making it work in MQL4. I'm sure it's simple, but, I just can't bring it together. I have the conditions for establishing a BO bar. I just need to set things properly for a comparison of the most recent BO bar with future bars and establish a mark on the first true instance of said comparison within y number of bars.

Any help much appreciated.

--------------
Bar x = BO bar
xL = BO long; xS = BO short
For y bars after xL and before any new xS bar, if close < open xL, mark bar as BI bar short (e.g. yS) but only for the first instance within the y bars checked
For y bars after xS and before any new xL bar, if close > open xS, mark bar as BI bar long (e.g. yL) but only for the first instance within the y bars checked
--------------


Reason: