This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
OlderNewer