November 2019
Beginner
394 pages
10h 31m
English
Let's now implement the absolute price oscillator, with the faster EMA using a period of 10 days and a slower EMA using a period of 40 days, and default smoothing factors being 2/11 and 2/41, respectively, for the two EMAs:
num_periods_fast = 10 # time period for the fast EMAK_fast = 2 / (num_periods_fast + 1) # smoothing factor for fast EMAema_fast = 0num_periods_slow = 40 # time period for slow EMAK_slow = 2 / (num_periods_slow + 1) # smoothing factor for slow EMAema_slow = 0ema_fast_values = [] # we will hold fast EMA values for visualization purposesema_slow_values = [] # we will hold slow EMA values for visualization purposesapo_values = [] # track computed absolute price oscillator values ...