def get(open, high, low, close, wrb, wrb_hg): """Calculate directional creeper movment Parameters ---------- Returns ------- """ size = open.shape[0] result = np.zeros(size, dtype=np.int8) most_recent_wrb = 0 last_dcm = 0 for i in range(size-3): # bull dcm if wrb_hg[i] == 1: # look for most recent bear wrb_hg for j in range(1, min(65, i)): if wrb_hg[i-j] == -1: most_recent_wrb = i-j break else: most_recent_wrb = 0 # check volatiliti contraction if (most_recent_wrb and close[i] > open[most_recent_wrb] and not dt.any(wrb[i+1:i+4]) and dt.nanmin(low[i+1:i+4]) > open[i] and dt.nanmin(close[i+1:i+4]) > close[i]): last_dcm = 1 elif last_dcm == -1: last_dcm = 0 # bear dcm if wrb_hg[i] == -1: # look for most recent bear wrb_hg for j in range(1, min(65, i)): if wrb_hg[i-j] == 1: most_recent_wrb = i-j break else: most_recent_wrb = 0 # check volatiliti contraction if (most_recent_wrb and close[i] < open[most_recent_wrb] and not dt.any(wrb[i+1:i+4]) and dt.nanmax(high[i+1:i+4]) < open[i] and dt.nanmax(close[i+1:i+4]) < close[i]): last_dcm = -1 elif last_dcm == 1: last_dcm = 0 result[i] = last_dcm return result
def get(open, high, low, close, wrb, wrb_hg): """Calculate directional creeper movment Parameters ---------- Returns ------- """ size = open.shape[0] result = np.zeros(size, dtype=np.int8) most_recent_wrb = 0 last_dcm = 0 for i in range(size - 3): # bull dcm if wrb_hg[i] == 1: # look for most recent bear wrb_hg for j in range(1, min(65, i)): if wrb_hg[i - j] == -1: most_recent_wrb = i - j break else: most_recent_wrb = 0 # check volatiliti contraction if (most_recent_wrb and close[i] > open[most_recent_wrb] and not dt.any(wrb[i + 1:i + 4]) and dt.nanmin(low[i + 1:i + 4]) > open[i] and dt.nanmin(close[i + 1:i + 4]) > close[i]): last_dcm = 1 elif last_dcm == -1: last_dcm = 0 # bear dcm if wrb_hg[i] == -1: # look for most recent bear wrb_hg for j in range(1, min(65, i)): if wrb_hg[i - j] == 1: most_recent_wrb = i - j break else: most_recent_wrb = 0 # check volatiliti contraction if (most_recent_wrb and close[i] < open[most_recent_wrb] and not dt.any(wrb[i + 1:i + 4]) and dt.nanmax(high[i + 1:i + 4]) < open[i] and dt.nanmax(close[i + 1:i + 4]) < close[i]): last_dcm = -1 elif last_dcm == 1: last_dcm = 0 result[i] = last_dcm return result
def contraction_fill(v1, v2, high, low, dir): if dir[v2] == 1: if dt.nanmin(low[v2+1:v1]) <= open[v2]: return True elif dir[v2] == -1: if dt.nanmax(high[v2+1:v1]) >= open[v2]: return True return False
def contraction_retrace(v1, v2, count, high, low, dir): if dir[v2] == 1: return dt.nanmin(low[v2 - 1 - count:v2 - 1]) <= dt.nanmin(low[v2 + 1:v1]) elif dir[v2] == -1: return dt.nanmax(high[v2 - 1 - count:v2 - 1]) >= dt.nanmax(high[v2 + 1:v1])
def strong_continuation4(open, high, low, close, dir, body_size, body_mid_point, bars_broken_by_body, wrb_hg): """Calculate wrb strong continuation def 3 zone Parameters ---------- candle open: int64[:] candle high: int64[:] candle low: double[:] candle dir: int64[:] candle body size: double[:] candle bars broken by body: int64[:] candle wrb hg: int64[:] Returns ------- int64[:] where strong continuation = 1 no strong continuation = 0 """ size = open.shape[0] result = np.zeros(size, dtype=np.int8) for v1 in range(4, size): # Look for V1 WRB HG if not wrb_hg[v1]: continue # Bullish Swing Point # Look for V2 for v2 in range(v1 - 4, v1 - QUANTUM_CONTRACTION, -1): # 4 + 64 = 68 # V2 wrb hg and must be bull if (dir[v1] == 1 and wrb_hg[v2] == 1 and # V1 body > V2 body and close V1 > close V2 body_size[v1] > body_size[v2] and close[v1] > close[2] and body_mid_point[v2] > dt.nanmin(close[v2 + 1:v1]) and # Contraction volatility must share min 1 pip with V2 contraction_share(v1, v2, high, low) and # V1 must breakout volatility contraction contraction_break(v1, v2, bars_broken_by_body) and # Body of V1/V2 must be greater than volatiliti # contraction contraction_body_size_break(v1, v2, body_size)): result[v1] = 1 break # Bearish Swing Point # V2 wrb hg and must be bear elif (dir[v1] == -1 and wrb_hg[v2] == -1 and # V1 body > V2 body and close V1 > close V2 body_size[v1] > body_size[v2] and close[v1] > close[2] and body_mid_point[v2] < dt.nanmin(close[v2 + 1:v1]) and # Contraction volatility must share min 1 pip with V2 contraction_share(v1, v2, high, low) and # V1 must breakout volatility contraction contraction_break(v1, v2, bars_broken_by_body) and # Body of V1/V2 must be greater than volatiliti # contraction contraction_body_size_break(v1, v2, body_size)): result[v1] = -1 break return result