Skip to content

Commit

Permalink
Aweseome Oscilator - added change to last value for color
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptocoinserver committed May 16, 2020
1 parent 8f8159c commit 3c1a147
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions jesse/indicators/ao.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import numpy as np
import talib
from typing import Union

from collections import namedtuple

def ao(candles: np.ndarray, sequential=False) -> Union[float, np.ndarray]:
AO = namedtuple('AO', ['osc', 'change'])

def ao(candles: np.ndarray, sequential=False) -> AO:
"""
Awesome Oscillator
Expand All @@ -18,4 +20,10 @@ def ao(candles: np.ndarray, sequential=False) -> Union[float, np.ndarray]:
med = talib.MEDPRICE(candles[:, 3], candles[:, 4])
res = talib.SMA(med,5) - talib.SMA(med,34)

return res if sequential else res[-1]
mom = talib.MOM(res, timeperiod=1)

if sequential:
return AO(res, mom)
else:
return AO(res[-1], mom[-1])

0 comments on commit 3c1a147

Please sign in to comment.