Help with syntax

I’d like to test an ETF portfolio that does the following:

  1. Invest in SPY if, during the prior month, (SPY + VTI)/2 > (IEF + TLT)/2 and if (SPY + VTI)/2 > 0
  2. Invest in TLT if, during the prior month, (SPY + VTI)/2 < (IEF + TLT)/2 and if (SPY + VTI)/2 > 0
  3. Otherwise, go to cash

Need help with writing the rules for this model.

Thanks in advance,
Ed