Multiple time frame strategy?

I am using 3 timeframes in my strategy, 1 hour, 15 min and 3 minutes
First I want to make sure that a bearish engulfing ( where open > close and open-close > close0.02) has formed on hourly timeframe in the last 10 hour candles, leaving the last one.
So lets say its currently 12 pm. So i want to leave out 11:30pm to 12:30 pm candle and test 10 hourly candles before that.
in addition to the above, I also want to make sure that bearish engulfing is formed on 15 min (where open > close and open-close > close
0.005) in the last 20 candles, leave the last one.
and then finally in the main timeframe I want the current candle to be bearish engulfing (where open > close and open-close > close*0.001). Please help me out, how do I code that. Below is the code which I tried but its not giving me correct results.

TimeFrameSet(inHourly);
greenhour = Open > Close AND Open-Close > Close * 0.02;

TimeFrameRestore();
TimeFrameSet(in15Minute);
greenfifteen = Open > Close AND Open-Close > Close * 0.005;

TimeFrameRestore();


hgreenhour = TimeFrameExpand(greenhour,inHourly,expandFirst);
hgreenfifteen = TimeFrameExpand(greenfifteen,in15Minute,expandFirst);


twogreenhour = Open > Close AND Open-Close > Close * 0.001;
Short = Ref(Sum(hgreenhour,100),-20) >=1 AND Ref(Sum(hgreenhour,100),-10) >=1 AND twogreenhour;

Main issue I am facing is that in both hourly and 15 min charts, I want bearish engulfing in the last 10/20 candles except the current running candle. So the current candle should not be considered while doing this.