Skip to content

Instantly share code, notes, and snippets.

View joeng03's full-sized avatar
🏠
Working from home

Yin Joe Ng joeng03

🏠
Working from home
View GitHub Profile
local_min_idx=argrelextrema(prices_low,np.less)[0]
local_max_idx=argrelextrema(prices_high,np.greater)[0]
local_min_idx=np.array(local_min_idx)
local_max_idx=np.array(local_max_idx)
local_min=[]
local_max=[]
for loc in local_min_idx:
local_min.append(prices_low[loc])
for loc in local_max_idx:
for i in range(0,len(local_max)-3):
(m,c),r,_,_,_= np.polyfit(local_max_idx[i:i+3],local_max[i:i+3],1,full=True)
if(m<=3 and m>=-3 and (r[0]<20 and r[0]>-20)):
start=local_max_idx[i+2]
for k in range(start,start+7):
if(k<len(prices_close) and prices_close[k]>(k*m+c)):
plt.figure(figsize=(10,5))
plt.plot(local_max_idx,m*local_max_idx+c,'m')
plt.plot(prices_close)
plt.plot(k,prices_close[k],'bo')