forked from sofienkaabar/the-book-of-trading-strategies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPattern_Hammer.py
49 lines (38 loc) · 1.59 KB
/
Pattern_Hammer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Base parameters
expected_cost = 0.5 * (lot / 10000)
assets = asset_list(1)
window = 1000
# Trading parameters
horizon = 'H1'
# Mass imports
my_data = mass_import(0, horizon)
# Defining the minimum width of the candle
body = 0.0004
wick = body * 2
def signal(Data):
for i in range(len(Data)):
# Hammer
if abs(Data[i, 3] - Data[i, 0]) < body and abs(Data[i, 2] - Data[i, 0]) > wick and Data[i, 1] == Data[i, 0]:
Data[i, 6] = 1
# Hammer
if abs(Data[i, 3] - Data[i, 0]) < body and abs(Data[i, 2] - Data[i, 0]) > wick and Data[i, 1] == Data[i, 3]:
Data[i, 6] = 1
# Shooting Star
if abs(Data[i, 3] - Data[i, 0]) < body and abs(Data[i, 1] - Data[i, 0]) > wick and Data[i, 2] == Data[i, 0]:
Data[i, 7] = -1
# Shooting Star
if abs(Data[i, 3] - Data[i, 0]) < body and abs(Data[i, 1] - Data[i, 0]) > wick and Data[i, 2] == Data[i, 3]:
Data[i, 7] = -1
############################################################################## 1
my_data = adder(my_data, 10)
my_data = rounding(my_data, 4)
signal(my_data)
if sigchart == True:
signal_chart_ohlc_color(my_data, assets[0], 3, 6, 7, window = 250)
holding(my_data, 6, 7, 8, 9)
my_data_eq = equity_curve(my_data, 8, expected_cost, lot, investment)
performance(my_data_eq, 8, my_data, assets[0])
plt.plot(my_data_eq[:, 3], linewidth = 1, label = assets[0])
plt.grid()
plt.legend()
plt.axhline(y = investment, color = 'black', linewidth = 1)