Trying to fix MA calculation. Not finished yet.