Call Price close for buy sell orders

 

Hello,

I am developing an EA and I want the buy order to be as follows:

Buy signal triggers when candle closed below moving average and above another moving average and also the previous candle ( would be 2 candles back)closed above a moving average.

Signal triggers when candle opens.

Can someone tell me how to code this ?, I have tried and the EA only places buy orders.

Thanks!

Reason: