-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathewo.py
28 lines (22 loc) · 834 Bytes
/
ewo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from typing import Union
import numpy as np
import talib
from jesse.helpers import get_candle_source, slice_candles
def ewo(candles: np.ndarray, short_period: int = 5, long_period: int = 35, source_type="close", sequential=False) -> \
Union[float, np.ndarray]:
"""
Elliot Wave Oscillator
:param candles: np.ndarray
:param short_period: int - default: 5
:param long_period: int - default: 34
:param source_type: str - default: close
:param sequential: bool - default: False
:return: Union[float, np.ndarray]
"""
candles = slice_candles(candles, sequential)
src = get_candle_source(candles, source_type)
ewo = np.subtract(talib.EMA(src, timeperiod=short_period), talib.EMA(src, timeperiod=long_period))
if sequential:
return ewo
else:
return ewo[-1]