""" Created on Tue Aug 5 14:48:52 2014 1) import data, sync H1 wih D1 2) find recent H/L 3) find isPullback - on D1 or better H1 4) play with parameters 5) is signal significant? 6) visualize results (with different script) @author: chew-z """ import read_mql as read_mql import formulas as formulas # 1 import data, sync H1 with D1 csv_listH1 = read_mql.csv_to_list('./data/EURUSD60_01.csv') csv_listD1 = read_mql.csv_to_list('./data/EURUSD1440_01.csv') d_mat = read_mql.convert_cells_to_floats(csv_listH1, 1, 3) closeH1 = d_mat[:, 3] highH1 = d_mat[:, 1] lowH1 = d_mat[:, 2] d_mat = read_mql.convert_cells_to_floats(csv_listD1, 1, 3) closeD1 = d_mat[:, 3] highD1 = d_mat[:, 1] lowD1 = d_mat[:, 2] D1, H1, s = read_mql.sync(csv_listH1, csv_listD1) del d_mat, csv_listD1, csv_listH1
# -*- coding: utf-8 -*- """ 1) Testing TA-Lib and it's cpython wraper Created on Fri Jun 27 23:09:39 2014 @author: chew-z """ #import numpy as np import matplotlib.pyplot import read_mql as mql import formulas as formulas d_mat = mql.convert_cells_to_floats( mql.csv_to_list('./data/USDJPY1440_01.csv'), 1, 3) close = d_mat[:, 3] high = d_mat[:, 1] low = d_mat[:, 2] del d_mat f_l = formulas.f_lookbackdays(close, EMA=60) hh, ll = formulas.f_hh_ll(f_l, high, low) is_recentHigh, is_recentLow = formulas.is_recent_HL(high, low, hh, ll, K=5) is_pullbackH, is_pullbackL = formulas.is_pullback(high, low, K=5) # wektorówki isPullback() # Plot close i stddev # matplotlib.pyplot.subplot(221) # matplotlib.pyplot.plot(stdev) #matplotlib.pyplot.title('std dev (close)') #
# -*- coding: utf-8 -*- """ Created on Tue Sep 30 18:21:52 2014 1) import data, D1 2) identify inside bars @author: chew-z """ import read_mql as read_mql import itertools import numpy as np # 1 import data, sync H1 with csv_listD1 = read_mql.csv_to_list('./data/USDJPY1440_03a.csv') d_mat = read_mql.convert_cells_to_floats(csv_listD1, 1, 3) openD1 = d_mat[:, 0] highD1 = d_mat[:, 1] lowD1 = d_mat[:, 2] closeD1 = d_mat[:, 3] del csv_listD1, d_mat # 2 identify inside bars BarSize = highD1 - lowD1 def motherBar(start, K): # zwraca indeks największej świecy x = BarSize[start - K:start].argmax() return x + (start - K)
2) Created on Fri Jul 05 19:44:39 2014 @author: chew-z """ # To ignore numpy errors: # pylint: disable=E1101 import numpy as np #import matplotlib.pyplot #import scipy.io as scio import formulas as formulas import rules as rules import read_mql as mql #d_mat = scio.loadmat("Close.mat") #Matlab matrix with H1Close & DMA200 d_mat = mql.convert_cells_to_floats(mql.csv_to_list('./data/USDJPY1440_03a.csv'), 1, 3) close = d_mat[:, 3] del d_mat xi = [] yj = [] results = [] for i in range(5, 100, 1): for j in range(i+5, 200, 1): entry = rules.sma_crossover(close, i, j, 1) #buy when MAs cross exit = rules.sma_exit(entry) #long exit = short entry t = zip(entry.nonzero()[0], exit.nonzero()[0]) #indexes of entry and exit paired returns = rules.returns(t, entry, close) drawdowns = rules.max_drawdown2(t, entry, close) if np.sum(returns) > 0.0:
# -*- coding: utf-8 -*- """ Created on Tue Sep 30 18:21:52 2014 1) import data, D1 2) identify inside bars @author: chew-z """ import read_mql as read_mql import numpy as np # 1 import data, sync H1 with D1 csv_listD1 = read_mql.csv_to_list('./data/USDCHF1440_01.csv') d_mat = read_mql.convert_cells_to_floats(csv_listD1, 1, 3) openD1 = d_mat[:, 0] highD1 = d_mat[:, 1] lowD1 = d_mat[:, 2] closeD1 = d_mat[:, 3] del csv_listD1 # 2 identify inside bars BarSize = highD1 - lowD1 def motherBar(start, K): # zwraca indeks największej świecy x = BarSize[start - K:start].argmax() return x + (start - K)
# -*- coding: utf-8 -*- """ Created on Tue Aug 19 09:16:52 2015 1) import data from Equity.csv 2) plot equity graph TODO - merge various ranges, plot date @author: chew-z """ import read_mql as read_mql import matplotlib.pyplot # 1 import data and select range csv_listEq = read_mql.csv_to_list('./data/Equity.csv', ',') eq_mat = read_mql.convert_cells_to_floats(csv_listEq, 0, 1) eq_t = read_mql.extract_timestamp_as_dt(csv_listEq, 0) t = range(2250, 2450) + range(3000, 3250) y = eq_mat[t, 1] x = eq_t[t] # 2 plot equity graph fig = matplotlib.pyplot # There is a tricky issue here # - if you plot with x (dates) the gaps in range are filled in automatically # - simple plot of y omits gaps in the range #fig.plot(x, y) fig.plot(y) # beautify the x-labels
# -*- coding: utf-8 -*- """ 1) Testing TA-Lib and it's cpython wraper Created on Fri Jun 27 23:09:39 2014 @author: chew-z """ import numpy as np import scipy.io as scio import matplotlib.pyplot import talib import read_mql as mql d_mat = mql.convert_cells_to_floats(mql.csv_to_list('./data/EURUSD60_01.csv'), 1, 3) close = d_mat[:, 3] del d_mat sma = talib.SMA(close) mx = talib.MAX(close, 1000) mn = talib.MIN(close, 1000) # Plot close i sma matplotlib.pyplot.plot(close) matplotlib.pyplot.plot(sma) matplotlib.pyplot.plot(mx) matplotlib.pyplot.plot(mn) matplotlib.pyplot.show()