wspace=.050, hspace=0.01) gl.savefig(folder_images + 'MAMAw.png', dpi=100, sizeInches=[2 * 8, 2 * 3]) if (HullsMA): # Some basic indicators. price = timeData.get_timeSeries(["Close"]) dates = timeData.get_dates() # For comparing SMA, EMA, WMA nHMA = 20 # Lag of different amplitudes. # HMA = indl.get_HMA(price, nHMA) WMA = indl.get_WMA(price, nHMA) HMAg = indl.get_HMAg(price, nHMA) # For lag and noise # Plotting the 3 of them at the same time. title = "Hull's MA. " + str( symbols[0]) + "(" + ul5.period_dic[timeData.period] + ")" gl.plot(dates, [price, HMA, HMAg, WMA], nf=1, AxesStyle="Normal", labels=[title, "", r"Price ($\$$)"], legend=[ "Price",
Target = Target # Increase in Close price Range_HL = H - L # measure of volatility Daily_gap = O - bMl.shift(C, lag=1).flatten() # measure of price movement ## Add the lagged value to the database Nlag_OCHL_information = 3 tut.add_lagged_values(data_df, Target, "Target", Nlag_OCHL_information) tut.add_lagged_values(data_df, Range_HL, "Range_HL", Nlag_OCHL_information) tut.add_lagged_values(data_df, Daily_gap, "Daily_gap", Nlag_OCHL_information) ################## Daily Trading Indicators #################### # Hulls_average !! ACDC, Volatility, ATR, Short nHMA = 20 ## Hulls Average, reactive but smoothing MA HMA = indl.get_HMA(timeData_daily.get_timeSeries(["Close"]), nHMA) ## Volatility nAHLR = 20 nBB = 20 nATR = 20 nCha = 20 AHLR = timeData_daily.AHLR(n=nAHLR) ATR = timeData_daily.ATR(n=nATR) EMA_Range, Cha = timeData_daily.Chaikin_vol(n=nCha) BB = timeData_daily.BBANDS(seriesNames=["Close"], n=nBB) BB = BB[:, 0] - BB[:, 1] # Oscillators n, SK, SD = 14, 6, 6 L = 14
def get_HMA(self, L): timeSeries = self.get_timeSeries() HMA = indl.get_HMA(timeSeries, L) return HMA
def get_HMA(self, L): if (self.timeSeries == []): # Check existence of timeSeries self.get_timeSeries() HMA = indl.get_HMA(self.timeSeries, L) return HMA
Target = Target # Increase in Close price Range_HL = H-L # measure of volatility Daily_gap = O - bMl.shift(C,lag = 1).flatten() # measure of price movement ## Add the lagged value to the database Nlag_OCHL_information = 3 tut.add_lagged_values(data_df,Target,"Target",Nlag_OCHL_information) tut.add_lagged_values(data_df,Range_HL,"Range_HL",Nlag_OCHL_information) tut.add_lagged_values(data_df,Daily_gap,"Daily_gap",Nlag_OCHL_information) ################## Daily Trading Indicators #################### # Hulls_average !! ACDC, Volatility, ATR, Short nHMA = 20 ## Hulls Average, reactive but smoothing MA HMA = indl.get_HMA(timeData_daily.get_timeSeries(["Close"]), nHMA) ## Volatility nAHLR = 20; nBB = 20; nATR = 20; nCha = 20; AHLR = timeData_daily.AHLR(n = nAHLR) ATR = timeData_daily.ATR(n = nATR) EMA_Range, Cha = timeData_daily.Chaikin_vol(n = nCha) BB = timeData_daily.BBANDS(seriesNames = ["Close"], n = nBB) BB = BB[:,0] - BB[:,1] # Oscillators n , SK, SD = 14, 6,6 L = 14 L1 , L2, L3 = 14, 9,12 STO = timeData_daily.STO(n = n, SK = SK, SD = SD)
gl.subplots_adjust(left=.09, bottom=.10, right=.90, top=.95, wspace=.050, hspace=0.01) gl.savefig(folder_images +'MAMAw.png', dpi = 100, sizeInches = [2*8, 2*3]) if (HullsMA): # Some basic indicators. price = timeData.get_timeSeries(["Close"]); dates = timeData.get_dates() # For comparing SMA, EMA, WMA nHMA = 20 # Lag of different amplitudes. # HMA = indl.get_HMA(price, nHMA) WMA = indl.get_WMA(price, nHMA) HMAg = indl.get_HMAg(price, nHMA) # For lag and noise # Plotting the 3 of them at the same time. title = "Hull's MA. " + str(symbols[0]) + "(" + ul.period_dic[timeData.period]+ ")" gl.plot(dates, [price, HMA, HMAg, WMA] , nf = 1 ,AxesStyle = "Normal", labels = [title,"",r"Price ($\$$)"], legend = ["Price", "HMA(%i)"%nHMA, "HMAg(%i)"%nHMA, "WMA(%i)"%nHMA]) gl.savefig(folder_images +'HMA.png', dpi = 100, sizeInches = [2*8, 2*3])