1) if self.short_ma[3] == self.old_ema:
2) return
4) self.old_ema = self.short_ma[3]

The aim of the code above is to ONLY run scripts below line 4 whenever a Moving Average gets updated.

self.short_ma is a dict{} of EMA's, where self.short_ma[3] is but one of the moving averages.

In Initialise() self.old_ema = None. 

Then line 4 is reached updating self.old_ema to equal the current moving average value. 

This is where it gets weird... On reaching line 1, whenever self.short_ma[3] gets updated the self.old_ma value is automatically updated too... without ever reaching line 4. So the code in line 4 is effectively getting executed on each pass even though it is only being reached ONCE, on the inital assignment.

Why is that? It's almost like they are pointing to the same place in memory so that whenever the EMA gets updated the self.old_ma is automatically receiving the new value (when I want it to store the old value). 

Do I perhaps need to use a rolling window instead?