The answer to your question is covered in the Knowledge Base:
http://www.amibroker.com/kb/2014/09/20/broad-market-timing-in-system-formulas/
In short you have to run the backtest on watchlist of TWO symbols (SPY and TLT) and use the code like this:
Buy = ... your original buy rule (for SPY)
Sell = ... your original sell rule (for SPY)
if( Name() == "TLT" )
{
// swap the rules
Tmp = Sell;
Sell = Buy;
Buy = Tmp;
}
There are plenty of other posts on this forum covering that already, see: https://forum.amibroker.com/search?q=pair
Last but not least, your user account isn't marked with License verified badge. Did you purchase AmiBroker license?
Only users with License verified badge are allowed to post on this forum.
So before posting, make sure you verify your license as explained here.