Script to trade on alert

 
I have a template and an indicator.

Is it possible to write a script to buy/sell when they both alert? Within a number of candles if they dont line up on the same candle?

For example if both indicators say buy within 10 candles, then execute buy order.

I want to write this myself, just looking for direction, not someone to do it for me.

I am having trouble uploading a screen shot of my alerts.