From my very limited knowledge of AmiBroker Formula Language (AFL) and Spanish, I think the logic from the comment for the original code at the end is
if in long trade
if close(intermarketAsset) > SimpleMovingAverage(intermarketAsset, 4)
and close(tradingAsset) >...