Why am I getting a different result?

SPYCLS = Foreign( “SPY”, “Close”, True );
ShowMe = ParamToggle( “TimeFrame Mode”, “COMPRESS|SET” );

if( ShowMe )
{
mc = TimeFrameCompress( SPYCLS, inMonthly );
monthlyma = ROC( mc, 1 );
}
else
{
TimeFrameSet( inMonthly );
monthlyma = ROC( SPYCLS, 1 );
TimeFrameRestore();
}

monthlyma = TimeFrameExpand( monthlyma, inMonthly );
Plot( monthlyma, “MontlyMA”, colorGreen );

As described in MANUAL http://www.amibroker.com/f?timeframeset
TimeFrameSet sets OHLC V arrays, NOT other arrays. So your code

monthlyma = ROC( SPYCLS, 1 );

operates on UNCOMPRESSED SPYCLS array.