help on EA

 
pls can anybody help me on this strategy by put it in an EA? This is the strategy. I want the EA to be calculating the first to the fiveth candlestic closing and divided them by five. This is how it will be placing order. If the result is higher than the present price its should place buy and if the result is lower than the present price it should place sell
 

O

Something like this?

double dSignal;

  dSignal = (Close[5]+Close[4]+Close[3]+Close[2]+Close[1])/5;

  if (dSignal > Ask) 
    {

      // Do your Buy here

    }


  if (dSignal < Bid) 
    {

      // Do your Sell here

    }

FWIW

-BB-