-
Notifications
You must be signed in to change notification settings - Fork 2
/
strategy4h.py
252 lines (192 loc) · 10.1 KB
/
strategy4h.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
from curses import KEY_A1
from analyzers import bollinger
from operator import truediv
from analyzers import willr
from analyzers import rsi
from analyzers import ichimoku
from analyzers import stochastic
from test import get_data
from send_to_channel import send
import time
from analyzers import adx
import cufflinks as cf
pairs=['BTC-USDT','ETH-USDT','ADA-USDT','AXS-USDT','SOL-USDT','IOST-USDT','FLOW-USDT','XMR-USDT','ETC-USDT','XTZ-USDT'
,'EGLD-USDT','SAND-USDT','ADA-USDT','XRP-USDT','CAKE-USDT','DOGE-USDT','DOT-USDT','AVAX-USDT','MATIC-USDT'
,'ALGO-USDT','ICP-USDT','VET-USDT','AAVE-USDT','AXS-USDT','UNI-USDT','FIL-USDT','SHIB-USDT','EOS-USDT','KCS-USDT'
,'LTC-USDT','ATOM-USDT','LINK-USDT','BCH-USDT','TRX-USDT','XLM-USDT','MANA-USDT','HBAR-USDT','APE-USDT','FTM-USDT','GRT-USDT'
,'THETA-USDT','MKR-USDT','DYP-USDT']
class bcolors:
OK = '\033[92m' #GREEN
DOWN = '\033[93m' #YELLOW
UP = '\033[91m' #RED
RESET = '\033[0m' #RESET COLOR
timeframe='4h'
for pair in pairs:
adxs = adx.Adx()
ohlc =get_data(pair,timeframe)
stoch = stochastic.STOCH.analyze(ohlc)
willrs=willr.willr(ohlc,14)
rsis = rsi.RSI.analyze(ohlc,14)
ichim=ichimoku.Ichimoku()
ichimokus = ichim.analyze(ohlc)
Dmi = adxs.analyze(ohlc,14)
bollinger_bands = bollinger.Bollinger()
bollingers = bollinger_bands.analyze(ohlc)
ichi_count = ichimokus.shape[0]-1
bollinger_count = bollingers.shape[0]-1
dmi_count = Dmi.shape[0]-1
rsi_count = rsis.shape[0]-1
willr_count = willrs.shape[0]-1
stoch_count = stoch.shape[0]-1
ohlc_count = ohlc.shape[0]-1
close1 = ohlc.close[ohlc_count]
close2 = ohlc.close[ohlc_count-1]
close3 = ohlc.close[ohlc_count-2]
close4 = ohlc.close[ohlc_count-3]
close5 = ohlc.close[ohlc_count-4]
rsi1 = rsis.rsi[rsi_count]
rsi2 = rsis.rsi[rsi_count-1]
rsi3 = rsis.rsi[rsi_count-2]
rsi4 = rsis.rsi[rsi_count-3]
rsi5 = rsis.rsi[rsi_count-4]
rsi6 = rsis.rsi[rsi_count-5]
upband1 = bollingers.up_band[bollinger_count]
upband2 = bollingers.up_band[bollinger_count-1]
upband3 = bollingers.up_band[bollinger_count-2]
upband4 = bollingers.up_band[bollinger_count-3]
upband5 = bollingers.up_band[bollinger_count-4]
lowband1 = bollingers.low_band[bollinger_count]
lowband2 = bollingers.low_band[bollinger_count-1]
lowband3 = bollingers.low_band[bollinger_count-2]
lowband4 = bollingers.low_band[bollinger_count-3]
lowband5 = bollingers.low_band[bollinger_count-4]
chico1 = ichimokus.chikou_span[ichi_count]
chico2 = ichimokus.chikou_span[ichi_count-1]
chico3 = ichimokus.chikou_span[ichi_count-2]
chico4 = ichimokus.chikou_span[ichi_count-3]
chico5 = ichimokus.chikou_span[ichi_count-4]
chico6 = ichimokus.chikou_span[ichi_count-5]
willr1 = willrs.willr[willr_count]
willr2 = willrs.willr[willr_count-1]
willr3 = willrs.willr[willr_count-2]
willr4 = willrs.willr[willr_count-3]
willr5 = willrs.willr[willr_count-4]
willr6 = willrs.willr[willr_count-5]
k1 = stoch.slowk[stoch_count]
k2 = stoch.slowk[stoch_count-1]
k3 = stoch.slowk[stoch_count-2]
k4 = stoch.slowk[stoch_count-3]
k5 = stoch.slowk[stoch_count-4]
k6 = stoch.slowk[stoch_count-5]
adx1 = Dmi.adx[dmi_count]
adx2 = Dmi.adx[dmi_count-1]
adx3 = Dmi.adx[dmi_count-2]
adx4 = Dmi.adx[dmi_count-3]
adx5 = Dmi.adx[dmi_count-4]
d1 = stoch.slowd[stoch_count]
d2 = stoch.slowd[stoch_count-1]
d3 = stoch.slowd[stoch_count-2]
d4 = stoch.slowd[stoch_count-3]
d5 = stoch.slowd[stoch_count-4]
d6 = stoch.slowd[stoch_count-5]
print("rsi :"+str(rsi1))
print("chico :"+str(chico1))
print("willr :"+str(willr1))
print("k1 :"+str(k1))
print("d1 :"+str(d1))
message=""
# 1th candle
if(willr1<willr2 and willr3<willr2 and willr2>-10):
if(rsi1>=58 and rsi1>rsi2):
if(d1>k1 and d2<k2 and d2>=80 and k2>=80):
if close1>=upband1:
#if(adx1>=32 or adx1<=18):
print(bcolors.DOWN+"down signal 1th candle"+bcolors.RESET)
print(bcolors.DOWN+"price is: "+str(close1)+bcolors.RESET)
message = pair+"\n"+"time frame: "+str(timeframe)+"\n"+"SELL signal 1th candle"+"\n"+"price is: "+str(close1)+"\n"+"adx is:"+str(adx1)
send(message)
elif(willr1>willr2 and willr3>willr2 and willr2<-90 ):
if(rsi1<=42 and rsi1<rsi2):
if(d1<k1 and d2>k2 and d2<=20 and k2<=20):
if(close1<=lowband1):
#if(adx1>=32 or adx1<=18):
print(bcolors.UP+"up signal 1th candle"+bcolors.RESET)
print(bcolors.UP+"price is: "+str(close1)+bcolors.RESET)
message = pair+"\n"+"time frame: "+str(timeframe)+"\n"+"BUY signal 1th candle"+"\n"+"price is: "+str(close1)+"\n"+"adx is:"+str(adx1)
send(message)
# message=""
# #2th candle
# if(willr2<willr3 and willr4<willr3 and willr3>-10):
# if(rsi2>=58 and rsi2>rsi3):
# if(d2>k2 and d3<k3 and d3>=80 and k3>=80):
# if close1>=upband1:
# print(bcolors.DOWN+"down signal 2th candle"+bcolors.RESET)
# print(bcolors.DOWN+"price is: "+str(close2)+bcolors.RESET)
# if(rsi_checked==True):
# message = pair+"\n"+"time frame: "+str(timeframe)+"\n"+"SELL signal 2th candle"+"\n"+"price is: "+str(close2)+"\n"+"rsi checked"
# elif(rsi_checked==False):
# message = pair+"\n"+"time frame: "+str(timeframe)+"\n"+"SELL signal 2th candle"+"\n"+"price is: "+str(close2)
# send(message)
# elif(willr2>willr3 and willr4>willr3 and willr3<-90 ):
# if(rsi2<=42 and rsi2<rsi3):
# if(d2<k2 and d3>k3 and d3<=20 and k3<=20):
# if close1<=lowband1:
# print(bcolors.UP+"up signal 2th candle"+bcolors.RESET)
# print(bcolors.up+"price is: "+str(close2)+bcolors.RESET)
# if(rsi_checked==True):
# message = pair+"\n"+"time frame: "+str(timeframe)+"\n"+"BUY signal 2th candle"+"\n"+"price is: "+str(close2)+"\n"+"rsi checked"
# elif(rsi_checked==False):
# message = pair+"\n"+"time frame: "+str(timeframe)+"\n"+"BUY signal 2th candle"+"\n"+"price is: "+str(close2)
# send(message)
# message=""
# rsi_checked=False
# #3th candle
# if(willr3<willr4 and willr5<willr4 and willr4>-10):
# if(rsi3>=58 and rsi3>rsi4):
# if(d3>k3 and d4<k4 and d4>=80 and k4>=80):
# if close1>=upband1:
# print(bcolors.DOWN+"down signal 3th candle"+bcolors.RESET)
# print(bcolors.DOWN+"price is: "+str(close3)+bcolors.RESET)
# if(rsi_checked==True):
# message = pair+"\n"+"time frame: "+str(timeframe)+"\n"+"SELL signal 3th candle"+"\n"+"price is: "+str(close3)+"\n"+"rsi checked"
# elif(rsi_checked==False):
# message = pair+"\n"+"time frame: "+str(timeframe)+"\n"+"SELL signal 3th candle"+"\n"+"price is: "+str(close3)
# send(message)
# elif(willr3>willr4 and willr5>willr4 and willr4<-90 ):
# if(rsi3<=42 and rsi3<rsi4):
# if(d3<k3 and d4>k4 and d4<=20 and k4<=20):
# if(close1<=lowband1):
# print(bcolors.UP+"up signal 3th candle"+bcolors.RESET)
# print(bcolors.up+"price is: "+str(close3)+bcolors.RESET)
# if(rsi_checked==True):
# message = pair+"\n"+"time frame: "+str(timeframe)+"\n"+"BUY signal 3th candle"+"\n"+"price is: "+str(close3)+"\n"+"rsi checked"
# elif(rsi_checked==False):
# message = pair+"\n"+"time frame: "+str(timeframe)+"\n"+"BUY signal 3th candle"+"\n"+"price is: "+str(close3)
# send(message)
# message=""
# rsi_checked=False
# # 4th candle
# if(willr3<willr5 and willr6<willr5 and willr5>-10):
# if(rsi4>=58 and rsi4>rsi5):
# rsi_checked=True
# if(d4>k4 and d5<k5 and d5>=80 and k5>=80):
# if close1>=upband1:
# print(bcolors.DOWN+"down signal 4th candle"+bcolors.RESET)
# print(bcolors.DOWN+"price is: "+str(close4)+bcolors.RESET)
# if(rsi_checked==True):
# message = pair+"\n"+"time frame: "+str(timeframe)+"\n"+"SELL signal 4th candle"+"\n"+"price is: "+str(close4)+"\n"+"rsi checked"
# elif(rsi_checked==False):
# message = pair+"\n"+"time frame: "+str(timeframe)+"\n"+"SELL signal 4th candle"+"\n"+"price is: "+str(close4)
# send(message)
# elif(willr4>willr5 and willr6>willr5 and willr5<-90 ):
# if(rsi4<=42 and rsi4<rsi5):
# rsi_checked=True
# if(d4<k4 and d5>k5 and d5<=20 and k5<=20):
# if(close1<=lowband1):
# print(bcolors.UP+"up signal with 4th candle"+bcolors.RESET)
# print(bcolors.up+"price is: "+str(close4)+bcolors.RESET)
# if(rsi_checked==True):
# message = pair+"\n"+"time frame: "+str(timeframe)+"\n"+"BUY signal 4th candle"+"\n"+"price is: "+str(close4)+"\n"+"rsi checked"
# elif(rsi_checked==False):
# message = pair+"\n"+"time frame: "+str(timeframe)+"\n"+"BUY signal 4th candle"+"\n"+"price is: "+str(close4)
# send(message)