MA and RES/SUP strategy

 

Hi,

I am working on a trading systems based on MAs and Sup/Res levels. The idea is if án MA and SUP/RES are very close to each other and price touches that level and bounces back to open an order. One could code that like this:

if(low < MA && low < RES level && close > MA && close > RES level)

            {place buy order}

and for short vis versa.

However, working like that limits the concept, inter alia, to a bounce back based on one candle and limits the flexibility overall. Is there any concept/idea/approach to give that strategy more flexibility? I.e. to make that work with more than one candle...

Reason: