How to test conditions before taking trade in expert advisor

 
Dear Friends:

I need to test two parameters 8 or more bars before taking a trade which trade then must meet certain conditions

First If Parameter1[range of bars] is True and Parameter2[another range of bars] Is True
Then If Close[i] < iMA_Custom[i]
OpenOrder() ....

Is anyone familiar with an example of such an advisor that I may reference and study? (perhaps at http://www.lightpatch.com/forex/mt_yahoo/ ) ?

Or perhaps some code snippet can be given?

Parameter1 is to test for sufficient price movement (trend) over a minimum amount of bars.

Parameter2 is to verify a retracement move of the previous move such that there are decreasing lows (or increasing highs) from the high (or low) of the Parameter1 range. I need only test on bar values and not tick data.

Thank you for your help!

nipperdj
Reason: