code to enter a trade ONLY at the time of crossing of 2 mva

 
Hi I need assistance with simple code that will only allow a trade at the time of crossing of 2 moving averages. Any help is appreciated.
 

1. get the FastMA value of previous bar and current bar (iMA() function)

2. do the same for SlowMA

3. Buy if(FastMA_Prev < SlowMA_Prev && FastMA_Now > SlowMA_Now)

4. Opposite of #3 for selling.

.

Jon