· 7 years ago · Nov 19, 2018, 02:12 AM
1
2Sub GetMyBittrexData()
3
4 Dim indexhis
5 Dim mrkname As String
6 Dim mrktrade As String
7 Dim pos As Integer
8 Dim pos2 As Integer
9 Dim pos3 As Integer
10 Dim pos4 As Integer
11 Dim tmphis As String
12 Dim JsonResponse As String
13 Dim Json As Object
14 Dim x As Long
15 Dim apikey As String
16 Dim secretkey As String
17
18 apikey = "xxxxxxxxxxxxxxxx"
19 secretkey = "xxxxxxxxxxxxxxxxxx"
20
21 t1 = DateToUnixTime("1/1/2014") 'included
22 t2 = DateToUnixTime("1/1/2018") 'excluded
23 indexSum = Range("A1", Range("A1").End(xlDown)).Rows.Count
24
25 If Range("A1").Value = 0 Then
26
27 Set J = New Json
28 x = 2
29 Debug.Print "getmarketsummaries"
30 JsonResponse = PublicBittrex("getmarketsummaries")
31 J.request JsonResponse
32 Debug.Print Left$(JsonResponse, 50)
33 Set obj = J.setJsonRoot("result")
34 Dim indexSum2
35
36 indexSum2 = J.getJsonObjectCount
37 If indexSum2 > 0 Then
38 For i = 0 To indexSum2 - 1
39
40 'set cell to the value of content field
41 'If j.getJsonArrayValue(i, "BaseVolume") > prcentbet Then
42 ' prcentbet = j.getJsonArrayValue(i, "BaseVolume")
43 'End If
44 Range("A1").Value = "Currency"
45 Range("A" & x).Value = J.getJsonArrayValue(i, "MarketName")
46 Range("A" & x).Interior.ColorIndex = 1
47 Range("A" & x).Font.ColorIndex = 48
48 Range("B1").Value = "Act"
49 Range("B" & x).Value = 0
50 Range("B" & x).Interior.ColorIndex = 1
51 Range("B" & x).Font.ColorIndex = 48
52 Range("C1").Value = "Notice"
53 Range("C" & x).Value = 0
54 Range("C" & x).Interior.ColorIndex = 1
55 Range("C" & x).Font.ColorIndex = 48
56 Range("D1").Value = "Balance"
57 Range("D" & x).Value = 0
58 Range("D" & x).Interior.ColorIndex = 1
59 Range("D" & x).Font.ColorIndex = 48
60 Range("E1").Value = "Bet"
61 Range("E" & x).Value = 0.001
62 Range("E" & x).Interior.ColorIndex = 1
63 Range("E" & x).Font.ColorIndex = 48
64 Range("F1").Value = "PdgBuy"
65 Range("F" & x).Value = 0
66 Range("F" & x).Interior.ColorIndex = 1
67 Range("F" & x).Font.ColorIndex = 48
68 Range("G1").Value = "PriceBuy"
69 Range("G" & x).Value = 0
70 Range("G" & x).Interior.ColorIndex = 1
71 Range("G" & x).Font.ColorIndex = 48
72 Range("H1").Value = "PendingSell"
73 Range("H" & x).Value = 0
74 Range("H" & x).Interior.ColorIndex = 1
75 Range("H" & x).Font.ColorIndex = 48
76 Range("I1").Value = "PriceSell"
77 Range("I" & x).Value = 0
78 Range("I" & x).Interior.ColorIndex = 1
79 Range("I" & x).Font.ColorIndex = 48
80 Range("J1").Value = "Quantity"
81 Range("J" & x).Value = 0
82 Range("J" & x).Interior.ColorIndex = 1
83 Range("J" & x).Font.ColorIndex = 48
84 Range("K1").Value = "sema"
85 Range("K" & x).Value = 10
86 Range("K" & x).Interior.ColorIndex = 1
87 Range("K" & x).Font.ColorIndex = 48
88 Range("L1").Value = "lema"
89 Range("L" & x).Value = 20
90 Range("L" & x).Interior.ColorIndex = 1
91 Range("L" & x).Font.ColorIndex = 48
92 Range("M1").Value = delay
93 Range("M" & x).Value = "00:02:00"
94 Range("M" & x).Interior.ColorIndex = 1
95 Range("M" & x).Font.ColorIndex = 48
96 Range("N1").Value = "N/A"
97 Range("N" & x).Value = "N/A"
98 Range("N" & x).Interior.ColorIndex = 1
99 Range("N" & x).Font.ColorIndex = 48
100 Range("O1").Value = "N/A"
101 Range("O" & x).Value = "N/A"
102 Range("O" & x).Interior.ColorIndex = 1
103 Range("O" & x).Font.ColorIndex = 48
104 Range("P1").Value = "N/A"
105 Range("P" & x).Value = "N/A"
106 Range("P" & x).Interior.ColorIndex = 1
107 Range("P" & x).Font.ColorIndex = 48
108 Range("Q1").Value = "N/A"
109 Range("Q" & x).Value = "N/A"
110 Range("Q" & x).Interior.ColorIndex = 1
111 Range("Q" & x).Font.ColorIndex = 48
112 Range("R1").Value = "N/A"
113 Range("R" & x).Value = "N/A"
114 Range("R" & x).Interior.ColorIndex = 1
115 Range("R" & x).Font.ColorIndex = 48
116 Range("S1").Value = "N/A"
117 Range("S" & x).Value = "N/A"
118 Range("S" & x).Interior.ColorIndex = 1
119 Range("S" & x).Font.ColorIndex = 48
120 Range("T1").Value = "N/A"
121 Range("T" & x).Value = "N/A"
122 Range("T" & x).Interior.ColorIndex = 1
123 Range("T" & x).Font.ColorIndex = 48
124 Range("U1").Value = "N/A"
125 Range("U" & x).Value = "N/A"
126 Range("U" & x).Interior.ColorIndex = 1
127 Range("U" & x).Font.ColorIndex = 48
128 Range("V1").Value = "N/A"
129 Range("V" & x).Value = "N/A"
130 Range("V" & x).Interior.ColorIndex = 1
131 Range("V" & x).Font.ColorIndex = 48
132 Range("W1").Value = "N/A"
133 Range("W" & x).Value = "N/A"
134 Range("W" & x).Interior.ColorIndex = 1
135 Range("W" & x).Font.ColorIndex = 48
136 Range("X1").Value = "N/A"
137 Range("X" & x).Value = "N/A"
138 Range("X" & x).Interior.ColorIndex = 1
139 Range("X" & x).Font.ColorIndex = 48
140 Range("Y1").Value = "N/A"
141 Range("Y" & x).Value = "N/A"
142 Range("Y" & x).Interior.ColorIndex = 1
143 Range("Y" & x).Font.ColorIndex = 48
144 Range("Z1").Value = "N/A"
145 Range("Z" & x).Value = "N/A"
146 Range("Z" & x).Interior.ColorIndex = 1
147 Range("Z" & x).Font.ColorIndex = 48
148 Range("AA1").Value = "N/A"
149 Range("AA" & x).Value = "N/A"
150 Range("AA" & x).Interior.ColorIndex = 1
151 Range("AA" & x).Font.ColorIndex = 48
152 Range("AB1").Value = "N/A"
153 Range("AB" & x).Value = "N/A"
154 Range("AB" & x).Interior.ColorIndex = 1
155 Range("AB" & x).Font.ColorIndex = 48
156 Range("AC1").Value = "N/A"
157 Range("AC" & x).Value = "N/A"
158 Range("AC" & x).Interior.ColorIndex = 1
159 Range("AC" & x).Font.ColorIndex = 48
160 Range("AD1").Value = "N/A"
161 Range("AD" & x).Value = "N/A"
162 Range("AD" & x).Interior.ColorIndex = 1
163 Range("AD" & x).Font.ColorIndex = 48
164 Range("AE1").Value = "total"
165 Range("AE" & x).Value = 0
166 Range("AE" & x).Interior.ColorIndex = 1
167 Range("AE" & x).Font.ColorIndex = 48
168 Range("AF1").Value = "positif"
169 Range("AF" & x).Value = 0
170 Range("AF" & x).Interior.ColorIndex = 1
171 Range("AF" & x).Font.ColorIndex = 48
172 Range("AG1").Value = "negatif"
173 Range("AG" & x).Value = 0
174 Range("AG" & x).Interior.ColorIndex = 1
175 Range("AG" & x).Font.ColorIndex = 48
176 Range("AH1").Value = "Fee"
177 Range("AH" & x).Value = 0.0025
178 Range("AH" & x).Interior.ColorIndex = 1
179 Range("AH" & x).Font.ColorIndex = 48
180 Range("AI1").Value = "N/A"
181 Range("AI" & x).Value = "N/A"
182 Range("AI" & x).Interior.ColorIndex = 1
183 Range("AI" & x).Font.ColorIndex = 48
184 Range("AJ1").Value = "N/A"
185 Range("AJ" & x).Value = "N/A"
186 Range("AJ" & x).Interior.ColorIndex = 1
187 Range("AJ" & x).Font.ColorIndex = 48
188 Range("AK1").Value = 0
189 Range("AK" & x).Value = "PriceSell"
190 Range("AK" & x).Interior.ColorIndex = 1
191 Range("AK" & x).Font.ColorIndex = 48
192 Range("AL1").Value = "Bid"
193 Range("AL" & x).Value = "N/A"
194 Range("AL" & x).Interior.ColorIndex = 1
195 Range("AL" & x).Font.ColorIndex = 48
196 Range("AM1").Value = "Ask"
197 Range("AM" & x).Value = "N/A"
198 Range("AM" & x).Interior.ColorIndex = 1
199 Range("AM" & x).Font.ColorIndex = 48
200 Range("AN1").Value = "Last"
201 Range("AN" & x).Value = "N/A"
202 Range("AN" & x).Interior.ColorIndex = 1
203 Range("AN" & x).Font.ColorIndex = 48
204 x = x + 1
205 Next
206
207 Else
208
209 End If
210 End If
211
212
213
214 Set J = New Json
215 Debug.Print "getbalance"
216 JsonResponse = PublicBittrex("getmarkets")
217 J.request JsonResponse
218 Debug.Print Left$(JsonResponse, 50)
219 Set obj = J.setJsonRoot("result")
220 Dim indexNot
221 indexSum = Range("A1", Range("A1").End(xlDown)).Rows.Count
222 indexNot = J.getJsonObjectCount
223 x = 2
224 If indexSum > 0 Then
225
226
227 For i = 0 To indexSum - 1
228 For g = 0 To indexNot - 1
229
230 Balcurrency = "BTC-" + J.getJsonArrayValue(g, "MarketCurrency")
231 If Range("A" & x).Value = Balcurrency Then
232 Range("C" & x).Value = J.getJsonArrayValue(g, "Notice")
233 End If
234 Next
235 x = x + 1
236 Next
237 End If
238
239
240
241
242 Application.Wait (Now + TimeValue("0:00:03"))
243 'GoTo NextIteration8
244 Set J = New Json
245 Debug.Print "getbalance"
246 JsonResponse = PrivateBittrex("account/getbalances", apikey, secretkey)
247 J.request JsonResponse
248 Debug.Print Left$(JsonResponse, 50)
249 Set obj = J.setJsonRoot("result")
250 Dim indexBal
251 indexSum = Range("A1", Range("A1").End(xlDown)).Rows.Count
252 indexBal = J.getJsonObjectCount
253
254
255
256
257
258
259
260
261
262
263 x = 2
264 If indexSum > 0 Then
265 Dim fixprcent() As String
266
267 For i = 0 To indexSum - 1
268 For g = 0 To indexBal - 1
269
270 Balcurrency = "BTC-" + J.getJsonArrayValue(g, "Currency")
271 If Range("A" & x).Value = Balcurrency Then
272 Range("D" & x).Value = J.getJsonArrayValue(g, "Available")
273 End If
274 Next
275 x = x + 1
276 Next
277 End If
278
279
280
281
282
283
284
285 x = 2
286 Application.Wait (Now + TimeValue("0:00:03"))
287 'https://bittrex.com/api/v1.1/market/getopenorders?apikey=API_KEY
288 Debug.Print "getopenorders"
289 Set J = New Json
290 JsonResponse = PrivateBittrex("market/getopenorders", apikey, secretkey)
291 J.request JsonResponse
292 'pos4 = InStr(JsonResponse, "APIKEY_INVALID")
293 'If pos4 < 40 Then
294 ' If pos4 < 50 Then
295 ' GoTo NextIteration
296 ' End If
297
298 ' End If
299 Debug.Print Left$(JsonResponse, 50)
300 Set obj = J.setJsonRoot("result")
301
302 Dim IndexOrder
303 IndexOrder = J.getJsonObjectCount
304 If indexSum > 0 Then
305 For i = 0 To indexSum - 1
306 Sheet1.Range("AJ" & x).ClearContents
307 Sheet1.Range("F" & x).ClearContents
308 Sheet1.Range("H" & x).ClearContents
309 'Sheet1.Range("S" & x).ClearContents
310 'Sheet1.Range("Q" & x).ClearContents
311 'Sheet1.Range("N" & x).ClearContents
312 Debug.Print Range("A" & x).Value
313 For g = 0 To IndexOrder - 1
314 OrderCurrency = J.getJsonArrayValue(g, "Exchange")
315 'OrderCurrency = "BTC-" + j.getJsonArrayValue(g, "Currency")
316 If Range("A" & x).Value = OrderCurrency Then
317
318 'Dim Tag As String
319 'Tag = "&market=ALL" '+ Range("A" & x).Value
320 'https://bittrex.com/api/v1.1/market/getopenorders?apikey=API_KEY&market=BTC-LTC
321 'JsonResponse = PrivateBittrex("market/getopenorders", apikey, secretkey, Tag)
322 'j.request JsonResponse
323 'Set obj = j.setJsonRoot("result")
324 'Debug.Print j.getJsonArrayValue(0, "OrderType")
325 If J.getJsonArrayValue(g, "OrderType") = ("LIMIT_BUY") Then
326 Sheet1.Range("F" & x).Value = J.getJsonArrayValue(g, "OrderType")
327 Sheet1.Range("H" & x).ClearContents
328 Sheet1.Range("AJ" & x).Value = J.getJsonArrayValue(g, "OrderUuid")
329 Sheet1.Range("G" & x).Value = J.getJsonArrayValue(g, "Limit")
330 ElseIf J.getJsonArrayValue(g, "OrderType") = ("LIMIT_SELL") Then
331 Sheet1.Range("G" & x).Value = J.getJsonArrayValue(g, "OrderType")
332 Sheet1.Range("F" & x).ClearContents
333 Sheet1.Range("AJ" & x).Value = J.getJsonArrayValue(g, "OrderUuid")
334 Sheet1.Range("I" & x).Value = J.getJsonArrayValue(g, "Limit")
335 Sheet1.Range("J" & x).Value = J.getJsonArrayValue(g, "Quantity")
336 Else
337 Sheet1.Range("J" & x).Value = "0"
338 End If
339 GoTo NextIteration5
340 Else
341
342 End If
343
344
345
346
347
348 Next
349NextIteration5:
350 ' setprcentcurrency (x)
351 x = x + 1
352
353 Next
354NextIteration4:
355
356
357
358 End If
359
360 Application.Wait (Now + TimeValue("0:00:01"))
361
362
363
364
365x = 2
366If indexSum > 0 Then
367 For i = 0 To indexSum - 1
368 If Left((Range("B" & x).Value), 1) = 1 Then
369 If Range("C" & x).Value = 0 Then
370 Set J = New Json
371 mrkname = "?market=" & Range("A" & x).Value
372 'https://bittrex.com/api/v1.1/public/getmarkethistory?market=BTC-DOGE
373 JsonResponse = PublicBittrex("getticker", mrkname)
374 J.request JsonResponse
375 'Debug.Print Left$(JsonResponse, 50)
376 tmphis = Chr(58) + "[]" + Chr(125)
377 pos = InStr(JsonResponse, "null")
378 pos2 = InStr(JsonResponse, tmphis)
379 pos3 = InStr(JsonResponse, "Time-out")
380 If pos > 38 Or pos2 > 37 Or pos3 > 37 Then
381 If pos2 < 39 Then
382 GoTo NextIteration7
383 End If
384 'Range("I" & x).Value = 0
385 If pos > 38 Then
386 GoTo NextIteration7
387 End If
388 End If
389 Set obj = J.setJsonRoot("result")
390 Dim timedelay As Double
391 Dim etimedelay As Double
392 Dim tstamp As Double
393 Dim dstamp As Double
394 'timedelay = "yyyy-MM-dd hh:mm:ss"
395 timedelay = Round(TimeValue("00:02:00"), 15) * 1
396 If Range("O" & x).Value = 0 Then
397 Range("O" & x).Value = "00:10:00"
398 timedelaytmp = Round(Range("O" & x).Value, 15)
399 Else
400 timedelaytmp = Round(Range("O" & x).Value, 15)
401 End If
402 'Dim edtmp
403 If Range("M" & x).Value = 0 Then
404 Range("M" & x).Value = "00:10:00"
405 etimedelaytmp = Round(Range("M" & x).Value, 15)
406 Else
407 etimedelaytmp = Round(Range("M" & x).Value, 15)
408 End If
409 'etimedtmp = Range("M" & x).Value
410 'etimedelaytmp = Round(TimeValue(Range("M" & x).Value), 15) * 1
411 ts = format(Now(), "yyyy-MM-dd hh:mm:ss")
412 ts = Split(ts, Chr(32))
413 dstamp = DateValue(ts(0))
414 tstamp = Round(TimeValue(ts(1)), 15) * 1
415 tsa = Split(tstamp, Chr(44))
416 tstamp = tsa(1)
417 timestamp = dstamp & "," & tstamp
418 tmpbid = J.getJsonObjectValue("result.Bid")
419 tmpask = J.getJsonObjectValue("result.Ask")
420 tmplast = J.getJsonObjectValue("result.Last")
421
422
423 Dim histcell(0 To 20000)
424 Dim ehistcell(0 To 20000)
425 Dim fn As Variant
426 fn = Split(Range("AN" & x).Value, Chr(126))
427 If fn(0) = "N/A" Then
428 GoTo nextstep
429 End If
430 Dim en As Variant
431 tmpchq = tmplast - (fn(3) * 1)
432 If tmplast > (fn(3) * 1) Then
433 tmpadva = tmplast - (fn(3) * 1)
434 tmpdecl = 0
435 ElseIf tmplast < (fn(3) * 1) Then
436 tmpdecl = (fn(3) * 1) - tmplast
437 tmpadva = 0
438 Else
439 tmpadva = 0
440 tmpdecl = 0
441 End If
442 'Columns(2), Columns(5)
443
444
445
446
447 en = Array(timestamp, tmpbid, tmpask, tmplast, tmpchq, tmpadva, tmpdecl, tmpavggain, tmpavgloss, tmprs, tmprsi, tmpsema, tmplema, tmp1rtb, tmp2rtb, tmp3rtb, tmpeb, tmp1rts, tmpes, tmpep, tmpextr)
448 histstart = 40
449 eretest = 20000
450
451
452 ladjust = 0.02
453 sadjust = -0.02
454 rsibase = Range("N" & x).Value
455 semabase = Range("K" & x).Value
456 lemabase = Range("L" & x).Value
457 If Range("K" & x).Value > (Range("L" & x).Value / 3) * 2 Then
458 Range("K" & x).Value = Round((Range("L" & x).Value / 3) * 2, 0)
459 End If
460 Dim rsicompare(0 To 3)
461 Dim compare(0 To 3)
462 Dim rsictmp
463 rsictmp = 0
464 For ia = 1 To 4
465
466 periods = rsibase
467 If rsibase < 11 Then
468 rsibase = 11
469 End If
470 sema = semabase
471 lema = lemabase
472 If semabase < 6 Then
473 semabase = 6
474 ElseIf lemabase < 11 Then
475 lemabase = 11
476 End If
477 timedelay = timedelaytmp
478 etimedelay = etimedelaytmp
479 If ia > 1 And ia < 5 Then
480 If ia = 2 Then etimedelay = (etimedelaytmp + (etimedelaytmp * ladjust)): timedelay = (timedelaytmp + (timedelaytmp * ladjust)): 'sema = sema: lema = lema: periods = rsibase
481 If ia = 3 Then etimedelay = (etimedelaytmp + (etimedelaytmp * sadjust)): timedelay = (timedelaytmp + (timedelaytmp * sadjust)): 'sema = sema - 1:
482 If ia = 4 Then: 'sema = sema + 1:
483 If ia = 5 Then: 'lema = lema - 1: 'periods = periods - 1: timedelay = (timedelaytmp + (timedelaytmp * ladjust))
484 If ia = 6 Then: 'lema = lema + 1: 'periods = periods + 1: timedelay = (timedelaytmp + (timedelaytmp * ladjust))
485 If ia = 7 Then: 'sema = sema - 1: lema = lema - 1: 'periods = periods - 1: timedelay = (timedelaytmp + (timedelaytmp * sadjust))
486 If ia = 8 Then: 'sema = sema - 1: lema = lema + 1: 'periods = periods + 1: timedelay = (timedelaytmp + (timedelaytmp * sadjust))
487 If ia = 9 Then: 'sema = sema + 1: lema = lema - 1: 'periods = periods - 1
488 If ia = 10 Then: 'sema = sema + 1: lema = lema + 1: 'periods = periods + 1
489
490 End If
491 If ia > 10 And ia < 20 Then
492 'etimedelay = (etimedelaytmp + (etimedelaytmp * ladjust))
493 If ia = 11 Then: 'sema = sema: lema = lema
494 If ia = 12 Then: 'sema = sema - 1
495 If ia = 13 Then: 'sema = sema + 1
496 If ia = 14 Then: 'lema = lema - 1
497 If ia = 15 Then: 'lema = lema + 1
498 If ia = 16 Then: 'sema = sema - 1: lema = lema - 1
499 If ia = 17 Then: 'sema = sema - 1: lema = lema + 1
500 If ia = 18 Then: 'sema = sema + 1: lema = lema - 1
501 If ia = 19 Then: 'sema = sema + 1: lema = lema + 1
502
503 End If
504 If ia > 19 And ia < 29 Then
505 'etimedelay = (etimedelaytmp + (etimedelaytmp * sadjust))
506 If ia = 20 Then: 'sema = sema: lema = lema
507 If ia = 21 Then: 'sema = sema - 1
508 If ia = 22 Then: 'sema = sema + 1
509 If ia = 23 Then: 'lema = lema - 1
510 If ia = 24 Then: 'lema = lema + 1
511 If ia = 25 Then: 'sema = sema - 1: lema = lema - 1
512 If ia = 26 Then: 'sema = sema - 1: lema = lema + 1
513 If ia = 27 Then: 'sema = sema + 1: lema = lema - 1
514 If ia = 28 Then: 'sema = sema + 1: lema = lema + 1
515
516 End If
517 actperiod = 1
518 eactperiod = 1
519 'eactretest = 1
520
521 hist = Range(Cells(x, histstart), Cells(x, (Cells(x, histstart).End(xlToRight).Column)))
522 For ii = 1 To UBound(hist, 2)
523 If actperiod > (periods - 1) And eactperiod > (sema - 1) And eactperiod > (lema - 1) And eactperiod > (eretest - 1) Then
524 Exit For
525 End If
526 If IsEmpty(hist(1, ii)) Then
527 Exit For
528 Else
529 'If actperiod > (periods - 1) Then
530 'Else
531 If ia < 5 Then
532 Dim tmphist As Variant
533 tmphist = Split(hist(1, ii), Chr(126))
534 If (tmphist(0) * 1) < (en(0) - (timedelay * actperiod) * 1) Then
535 If actperiod = 1 Then
536 If (tmphist(3) * 1) > (en(3) * 1) Then
537 tmphist(6) = (tmphist(3) * 1) - (en(3) * 1)
538 tmphist(5) = 0
539 ElseIf (tmphist(3) * 1) < (en(3) * 1) Then
540 tmphist(5) = (en(3) * 1) - (tmphist(3) * 1)
541 tmphist(6) = 0
542 Else
543 tmphist(5) = 0
544 tmphist(6) = 0
545 End If
546 Else
547 If (tmphist(3) * 1) > (histcell(actperiod - 1)(3) * 1) Then
548 tmphist(6) = (tmphist(3) * 1) - (histcell(actperiod - 1)(3) * 1)
549 tmphist(5) = 0
550 ElseIf (tmphist(3) * 1) < (histcell(actperiod - 1)(3) * 1) Then
551 tmphist(5) = (histcell(actperiod - 1)(3) * 1) - (tmphist(3) * 1)
552 tmphist(6) = 0
553 Else
554 tmphist(5) = 0
555 tmphist(6) = 0
556 End If
557 End If
558 tmphist(9) = ""
559 tmphist(10) = ""
560 actperiod = actperiod + 1
561 histcell(actperiod - 1) = Array(tmphist(0), tmphist(1), tmphist(2), tmphist(3), tmphist(4), tmphist(5), tmphist(6), tmphist(7), tmphist(8), tmphist(9), tmphist(10))
562
563
564 End If
565 End If
566 'End If
567 Dim etmphist As Variant
568 etmphist = Split(hist(1, ii), Chr(126))
569 If (etmphist(0) * 1) < (en(0) - (etimedelay * eactperiod) * 1) Then
570
571 eactperiod = eactperiod + 1
572 ehistcell(eactperiod - 1) = Array(etmphist(3), etmphist(11), etmphist(12), etmphist(13), etmphist(14), etmphist(15), etmphist(16), etmphist(17), etmphist(18), etmphist(19), etmphist(20))
573
574 End If
575
576
577 End If
578 Next
579 'Debug.Print 1
580 If ia < 5 Then
581 histcell(0) = Array(timestamp, tmpbid, tmpask, tmplast, tmpchq, tmpadva, tmpdecl, tmpavggain, tmpavgloss, tmprs, tmprsi)
582 rsipc = 1
583 rsitogglebuy = 0
584 For ii = 0 To UBound(histcell)
585 'If Range("P" & x).Value = 0 Then
586 'Else
587 ' If ia > 1 Then
588 ' Exit For
589 ' End If
590 'End If
591 Reverse = UBound(histcell) - ii
592 If IsEmpty(histcell(Reverse)) Then
593 Else
594
595
596 If rsipc > periods Then
597 sumadva = 0
598 sumdecl = 0
599 Dim iii
600 For iii = 0 To UBound(histcell)
601
602 'rvii = (periods - 1) - ii
603 If IsEmpty(histcell(Reverse + iii)) Then
604 Exit For
605 Else
606 If pdetect > (periods - 1) Then
607 Exit For
608 Else
609 End If
610
611 If (histcell(Reverse + iii)(5) * 1) = 0 And (histcell(Reverse + iii)(6) * 1) = 0 Then
612 Else
613 sumadva = sumadva + (histcell(Reverse + iii)(5) * 1)
614 pdetect = pdetect + 1
615 sumdecl = sumdecl + (histcell(Reverse + iii)(6) * 1)
616 End If
617 End If
618 Next
619 pdetect = 0
620 If sumdecl = 0 Or sumadva = 0 Then
621 If sumdecl = 0 Then sumdecl = 0.000000001
622 If sumadva = 0 Then sumdecl = 0.000000001
623 End If
624
625 sumadva = sumadva / periods
626 sumdecl = sumdecl / periods
627 histcell(Reverse)(7) = sumadva
628 histcell(Reverse)(8) = sumdecl
629 If histcell((Reverse + 1))(9) = "" Then
630 histcell(Reverse)(9) = (histcell(Reverse)(7) * 1) / (histcell(Reverse)(8) * 1)
631 Else
632 histcell(Reverse)(9) = (((histcell((Reverse + 1))(7) * (periods - 1)) + (histcell(Reverse)(5)) * 1) / periods) / (((histcell((Reverse + 1))(8) * (periods - 1)) + histcell(Reverse)(6)) / periods)
633 'If Range("A" & x).Value = "BTC-EBST" Then
634 'If Reverse = 1 Then
635 ' Debug.Print test
636 'End If
637 'End If
638 End If
639 If histcell((Reverse + 1))(10) = "" Then
640 histcell(Reverse)(10) = 100 - (100 / (1 + (histcell(Reverse)(9) * 1)))
641 Else
642 histcell(Reverse)(10) = 100 - (100 / (1 + (histcell(Reverse)(9) * 1)))
643
644 If (histcell(Reverse)(10) * 1) < 30 Then
645
646 If (histcell(Reverse)(10) * 1) < (histcell((Reverse + 1))(10) * 1) Or (histcell(Reverse)(10) * 1) = (histcell((Reverse + 1))(10) * 1) Then
647 Else
648
649 If ia = 4 Then
650 If Right((Range("B" & x).Value), 1) = 1 Then
651 If Range("P" & x).Value = 0 Then
652 If Reverse = 0 Then
653 If (Range("AC" & x).Value * 1) > 0 And (Range("AB" & x).Value * 1) > 0 Then
654 'https://bittrex.com/api/v1.1/public/getorderbook?market=BTC-LTC&type=sell
655NextIteration3:
656 Set J = New Json
657 mrkname = "?market=" & Range("A" & x).Value & "&" & "type=sell"
658 JsonResponse = PublicBittrex("getorderbook", mrkname)
659 J.request JsonResponse
660 'Debug.Print Left$(JsonResponse, 50)
661 tmphis = Chr(58) + "[]" + Chr(125)
662 pos = InStr(JsonResponse, "null")
663 pos2 = InStr(JsonResponse, tmphis)
664 pos3 = InStr(JsonResponse, "Time-out")
665 If pos > 38 Or pos2 > 37 Or pos3 > 37 Then
666 If pos2 < 39 Then GoTo NextIteration7
667 If pos > 38 Then GoTo NextIteration7
668 End If
669 Set obj = J.setJsonRoot("result")
670 IndexOrder = J.getJsonObjectCount
671 qtybuy = 0
672 qtyrate = 0
673 ratetotal = 0
674 For iii = 0 To IndexOrder
675 qtybuy = J.getJsonArrayValue(iii, "Quantity")
676 ratebuy = J.getJsonArrayValue(iii, "Rate")
677 ratetotal = ratetotal + ((qtybuy * 1) * (ratebuy * 1))
678 If ratetotal > (Range("E" & x).Value * 1) Then
679 Debug.Print "RSI Buy now"
680 tmpqty = ((Range("E" & x).Value * 1) / (ratebuy * 1))
681 tmpqty = Split(tmpqty, Chr(44))
682 qtyfinal = tmpqty(0) & "." & tmpqty(1)
683 tmpqty = Split(ratebuy, Chr(44))
684 ratefinal = tmpqty(0) & "." & tmpqty(1)
685 mrktrade = "&market=" & Range("A" & x).Value & "&quantity=" & qtyfinal & "&rate=" & ratefinal
686 'https://bittrex.com/api/v1.1/market/buylimit?apikey=API_KEY&market=BTC-LTC&quantity=1.2&rate=1.3
687 Set J = New Json
688 JsonResponse = PrivateBittrex("market/buylimit", apikey, secretkey, mrktrade)
689 J.request JsonResponse
690 Debug.Print Left$(JsonResponse, 100)
691 Set obj = J.setJsonRoot("result")
692 mrkuuid = J.getJsonObjectValue("result.uuid")
693 Range("AJ" & x).Value = mrkuuid
694 Range("P" & x).Value = (((Range("E" & x).Value * 1) / (ratebuy * 1)) * (ratebuy * 1)) + ((((Range("E" & x).Value * 1) / (ratebuy * 1)) * (ratebuy * 1)) * (Range("AH" & x).Value * 1))
695 Exit For
696 End If
697 Next
698 End If
699 Else
700 End If
701 End If
702 End If
703 Else
704 If rsitogglebuy = 1 Then
705 Else
706 rsibuy = (histcell(Reverse)(2) * 1)
707 rsitogglebuy = 1
708 End If
709 End If
710 End If
711
712
713 ElseIf (histcell(Reverse)(10) * 1) > 70 Then
714
715 'If (histcell(Reverse)(10) * 1) > (histcell((Reverse + 1))(10) * 1) Or (histcell(Reverse)(10) * 1) = (histcell((Reverse + 1))(10) * 1) Then
716 'Else
717
718
719 If ia = 4 Then
720 If Right((Range("B" & x).Value), 1) = 1 Then
721 If Range("P" & x).Value = 0 Then
722 Else
723 If Reverse = 0 Then
724NextIteration2:
725 Set J = New Json
726 mrkname = "?market=" & Range("A" & x).Value & "&" & "type=buy"
727 JsonResponse = PublicBittrex("getorderbook", mrkname)
728 J.request JsonResponse
729 'Debug.Print Left$(JsonResponse, 50)
730 tmphis = Chr(58) + "[]" + Chr(125)
731 pos = InStr(JsonResponse, "null")
732 pos2 = InStr(JsonResponse, tmphis)
733 pos3 = InStr(JsonResponse, "Time-out")
734 If pos > 38 Or pos2 > 37 Or pos3 > 37 Then
735 If pos2 < 39 Then GoTo NextIteration7
736 If pos > 38 Then GoTo NextIteration7
737 End If
738 Set obj = J.setJsonRoot("result")
739 IndexOrder = J.getJsonObjectCount
740 qtybuy = 0
741 qtyrate = 0
742 ratetotal = 0
743 For iii = 0 To IndexOrder
744 qtybuy = J.getJsonArrayValue(iii, "Quantity")
745 ratebuy = J.getJsonArrayValue(iii, "Rate")
746 ratetotal = ratetotal + ((qtybuy * 1) * (ratebuy * 1))
747 If ratetotal > ((Range("D" & x).Value * 1) * ratebuy) Then
748 Debug.Print "RSI sell now"
749 tmpqty = Split(Range("D" & x).Value, Chr(44))
750 qtyfinal = tmpqty(0) & "." & tmpqty(1)
751 tmpqty = Split(ratebuy, Chr(44))
752 ratefinal = tmpqty(0) & "." & tmpqty(1)
753 mrktrade = "&market=" & Range("A" & x).Value & "&quantity=" & qtyfinal & "&rate=" & ratefinal
754 'https://bittrex.com/api/v1.1/market/selllimit?apikey=API_KEY&market=BTC-LTC&quantity=1.2&rate=1.3
755 Set J = New Json
756 JsonResponse = PrivateBittrex("market/selllimit", apikey, secretkey, mrktrade)
757 J.request JsonResponse
758 Debug.Print Left$(JsonResponse, 100)
759 Set obj = J.setJsonRoot("result")
760 mrkuuid = J.getJsonObjectValue("result.uuid")
761 Range("AJ" & x).Value = mrkuuid
762 Range("Q" & x).Value = (((Range("D" & x).Value * 1) * (ratebuy * 1)) - (((Range("D" & x).Value * 1) * (ratebuy * 1)) * (Range("AH" & x).Value * 1))) - (Range("P" & x).Value * 1)
763 Range("P" & x).Value = 0
764 Debug.Print "RSI sell now profit = " & Range("Q" & x).Value
765 Exit For
766 End If
767 Next
768 End If
769 End If
770 End If
771 Else
772 If rsitogglebuy = 1 Then
773
774 rsicompare(ia) = (rsicompare(ia) * 1) + ((histcell(Reverse)(1) * 1) - rsibuy)
775 rsitogglebuy = 0
776 Else
777 End If
778
779 End If
780 'End If
781
782 End If
783 End If
784
785 Else
786 If (histcell(Reverse)(5) * 1) = 0 And (histcell(Reverse)(6) * 1) = 0 Then
787 Else
788 sumadva = sumadva + (histcell(Reverse)(5) * 1)
789 sumdecl = sumdecl + (histcell(Reverse)(6) * 1)
790 rsipc = rsipc + 1
791 End If
792 End If
793
794
795 End If
796 Next
797 sumadva = 0
798 sumdecl = 0
799 rsictmp = rsictmp + 1
800 rsitogglebuy = 0
801 rsipc = 0
802 End If
803 tmprsmac = 0
804 tmprsma = 0
805 lematmp = 0
806 ehistcell(0) = Array(en(3), etmphist(11), etmphist(12), etmphist(13), etmphist(14), etmphist(15), etmphist(16), etmphist(17), etmphist(18), etmphist(19), etmphist(20))
807 en(13) = fn(13)
808 en(14) = fn(14)
809 en(15) = fn(15)
810 en(16) = fn(16)
811 en(17) = fn(17)
812 en(18) = en(18)
813 For ii = 0 To UBound(ehistcell)
814 'If Range("R" & x).Value = 0 Then
815 'Else
816 ' If ia > 1 Then
817 ' Exit For
818 ' End If
819 'End If
820 Reverse = UBound(ehistcell) - ii
821 If IsEmpty(ehistcell(Reverse)) Then
822 Else
823 If ehistcell(Reverse)(8) = "" Then
824 Else
825 ehistcell(Reverse)(3) = ""
826 ehistcell(Reverse)(4) = ""
827 ehistcell(Reverse)(5) = ""
828 ehistcell(Reverse)(6) = ""
829 ehistcell(Reverse)(7) = ""
830 ehistcell(Reverse)(8) = ""
831 End If
832 'Debug.Print 1
833 If (tmprsmac * 1) > (sema - 1) Then
834 tmprsma = tmprsma - (ehistcell(Reverse + sema)(0) * 1) + (ehistcell(Reverse)(0) * 1)
835 'Debug.Print 2
836 multisema = 2 / (sema + 1)
837 ehistcell(Reverse)(1) = Round((((ehistcell(Reverse)(0) * 1) - (ehistcell(Reverse + 1)(1) * 1)) * multisema) + (ehistcell(Reverse + 1)(1) * 1), 15)
838 Else
839 tmprsma = tmprsma + (ehistcell(Reverse)(0) * 1)
840 If (tmprsmac * 1) = (sema - 1) Then
841 ehistcell(Reverse)(1) = tmprsma / sema
842 End If
843
844 End If
845 If (tmprsmac * 1) > (lema - 1) Then
846 lematmp = lematmp - (ehistcell(Reverse + lema)(0) * 1) + (ehistcell(Reverse)(0) * 1)
847 multilema = 2 / (lema + 1)
848 'Debug.Print 3
849 ehistcell(Reverse)(2) = Round((((ehistcell(Reverse)(0) * 1) - (ehistcell(Reverse + 1)(2) * 1)) * multilema) + (ehistcell(Reverse + 1)(2) * 1), 15)
850
851 If Reverse = 0 Then
852 en(11) = ehistcell(Reverse)(1)
853 en(12) = ehistcell(Reverse)(2)
854 End If
855
856 ehistcell(Reverse)(3) = ehistcell(Reverse + 1)(3)
857 ehistcell(Reverse)(4) = ehistcell(Reverse + 1)(4)
858 ehistcell(Reverse)(5) = ehistcell(Reverse + 1)(5)
859 ehistcell(Reverse)(6) = ehistcell(Reverse + 1)(6)
860 ehistcell(Reverse)(7) = ehistcell(Reverse + 1)(7)
861 ehistcell(Reverse)(8) = ehistcell(Reverse + 1)(8)
862 If (ehistcell(Reverse)(2) * 1) > (ehistcell(Reverse)(1) * 1) Then
863 eretestut = 0
864 ecrossdt = 1
865 ecrossut = 0
866 If (ehistcell(Reverse)(0) * 1) < (ehistcell(Reverse)(1) * 1) And (ehistcell(Reverse)(0) * 1) < (ehistcell(Reverse)(2) * 1) Then
867 If toggledt = 1 Then
868 toggleut = 0
869 togglect = 0
870 toggledt = 1
871 Else
872 eretestdt = eretestdt + 1
873 toggleut = 0
874 togglect = 0
875 toggledt = 1
876 End If
877 ElseIf (ehistcell(Reverse)(0) * 1) > (ehistcell(Reverse)(1) * 1) And (ehistcell(Reverse)(0) * 1) < (ehistcell(Reverse)(2) * 1) Then
878 If togglect = 1 Then
879 toggleut = 0
880 togglect = 1
881 toggledt = 0
882 Else
883 eretestdt = eretestdt + 1
884 toggleut = 0
885 togglect = 1
886 toggledt = 0
887 End If
888 ElseIf (ehistcell(Reverse)(0) * 1) > (ehistcell(Reverse)(1) * 1) And (ehistcell(Reverse)(0) * 1) > (ehistcell(Reverse)(2) * 1) Then
889 If toggleut = 1 Then
890 toggleut = 1
891 togglect = 0
892 toggledt = 0
893 Else
894 eretestdt = eretestdt + 1
895 toggleut = 1
896 togglect = 0
897 toggledt = 0
898 End If
899 End If
900 Else
901
902 If ecrossdt = 1 Then
903 en(13) = ""
904 en(14) = ""
905 en(15) = ""
906 en(16) = ""
907 en(17) = ""
908 en(18) = ""
909 End If
910 ecrossut = 1
911 ecrossdt = 0
912 eretestdt = 0
913 If (ehistcell(Reverse)(0) * 1) < (ehistcell(Reverse)(1) * 1) And (ehistcell(Reverse)(0) * 1) > (ehistcell(Reverse)(2) * 1) Then
914 If togglect = 1 Then
915 toggleut = 0
916 togglect = 1
917 toggledt = 0
918 Else
919 eretestut = eretestut + 1
920 toggleut = 0
921 togglect = 1
922 toggledt = 0
923 End If
924 ElseIf (ehistcell(Reverse)(0) * 1) > (ehistcell(Reverse)(1) * 1) And (ehistcell(Reverse)(0) * 1) > (ehistcell(Reverse)(2) * 1) Then
925 If toggleut = 1 Then
926 toggleut = 1
927 togglect = 0
928 toggledt = 0
929 Else
930 eretestut = eretestut + 1
931 toggleut = 1
932 togglect = 0
933 toggledt = 0
934 End If
935 ElseIf (ehistcell(Reverse)(0) * 1) < (ehistcell(Reverse)(1) * 1) And (ehistcell(Reverse)(0) * 1) < (ehistcell(Reverse)(2) * 1) Then
936 If toggledt = 1 Then
937 toggleut = 0
938 togglect = 0
939 toggledt = 1
940 Else
941 eretestut = eretestut + 1
942 toggleut = 0
943 togglect = 0
944 toggledt = 1
945 End If
946 End If
947 End If
948
949 'eretestdt = 3
950 If eretestdt = 2 And en(13) = 1 And en(14) = 1 And en(15) = 1 Then
951 en(17) = 1
952 en(18) = (ehistcell(Reverse)(0) * 1)
953 ehistcell(Reverse)(7) = 1
954 ehistcell(Reverse)(8) = (ehistcell(Reverse)(0) * 1) - ((ehistcell(Reverse)(0) * 1) * (Range("AH" & x).Value * 1))
955 'Range("AM" & x).Value = (ehistcell(Reverse)(0) * 1)
956
957 'Range("AK" & x).Value = Range("AK" & x).Value + ((ehistcell(Reverse)(0) * 1) - Range("AL" & x).Value)
958 eretestdt = 0
959 'Exit For
960 If ia = 4 Then
961 If Range("R" & x).Value = 0 Then
962 Else
963 If Reverse = 0 Then
964 'https://bittrex.com/api/v1.1/public/getorderbook?market=BTC-LTC&type=sell
965 Range("S" & x).Value = Round((((histcell(Reverse)(1) * 1) - Range("R" & x).Value) / (histcell(Reverse)(1) * 1)) * 100, 15)
966 Debug.Print "EMA sell now profit = " & Range("S" & x).Value
967 Range("R" & x).Value = 0
968 End If
969 End If
970 Else
971 compare(ia) = Round(compare(ia) + ((ehistcell(Reverse)(0) * 1) - en(16)), 15)
972 End If
973
974 End If
975
976 If en(13) = 1 And en(14) = 1 And en(15) = 1 Then
977 Else
978 If eretestut = 3 Then
979 en(13) = 1
980 ehistcell(Reverse)(3) = 1
981 ElseIf eretestut = 5 Then
982 en(14) = 1
983 ehistcell(Reverse)(4) = 1
984 ElseIf eretestut = 7 Then
985 en(15) = 1
986 ehistcell(Reverse)(5) = 1
987 en(16) = (ehistcell(Reverse)(0) * 1)
988 ehistcell(Reverse)(6) = (ehistcell(Reverse)(0) * 1) + ((ehistcell(Reverse)(0) * 1) * (Range("AH" & x).Value * 1))
989 'Range("AL" & x).Value = (ehistcell(Reverse)(0) * 1)
990 eretestut = 0
991 If ia = 4 Then
992 If Range("R" & x).Value = 0 Then
993 If Reverse = 0 Then
994 If (Range("AF" & x).Value * 1) > 0 And (Range("AE" & x).Value * 1) > 0 Then
995 ''https://bittrex.com/api/v1.1/public/getorderbook?market=BTC-LTC&type=buy
996 Range("R" & x).Value = (histcell(Reverse)(2) * 1)
997 Debug.Print "EMA Buy now"
998 End If
999 End If
1000 Else
1001 End If
1002 End If
1003 End If
1004 End If
1005 Else
1006 lematmp = lematmp + (ehistcell(Reverse)(0) * 1)
1007 If (tmprsmac * 1) = (lema - 1) Then
1008 ehistcell(Reverse)(2) = lematmp / lema
1009 End If
1010 End If
1011 tmprsmac = tmprsmac + 1
1012 End If
1013
1014
1015 Next
1016 Next
1017 For ii = 1 To UBound(rsicompare)
1018 'Reverse = UBound(rsicompare) - ii
1019 If ii = 1 Then
1020 rsicomparetmp = rsicompare(ii)
1021 rsicomparetmpc = ii
1022 End If
1023 If rsicompare(ii) > rsicomparetmp Then
1024 rsicomparetmp = rsicompare(ii)
1025 rsicomparetmpc = ii
1026 ElseIf rsicompare(1) = rsicompare(2) And rsicompare(2) = rsicompare(3) Then
1027 rsicomparetmpc = 0
1028 End If
1029 Next
1030 If Range("P" & x).Value = 0 Then
1031 Else
1032 'GoTo skiprsi
1033 End If
1034 If rsicomparetmpc = 0 Then
1035 modtemp = Round((timedelaytmp + (timedelaytmp * ladjust)), 15): Range("O" & x).Value = format(modtemp, "hh:mm:ss")
1036
1037 Else
1038 If rsicomparetmpc > 1 And rsicomparetmpc < 11 Then
1039 Range("O" & x).Value = timedelaytmp
1040
1041 If rsicomparetmpc = 2 Then modtemp = Round((timedelaytmp + (timedelaytmp * ladjust)), 15): Range("O" & x).Value = format(modtemp, "hh:mm:ss")
1042 If rsicomparetmpc = 3 Then modtemp = Round((timedelaytmp + (timedelaytmp * sadjust)), 15): Range("O" & x).Value = format(modtemp, "hh:mm:ss")
1043 If rsicomparetmpc = 4 Then:
1044 If rsicomparetmpc = 5 Then: 'Range("N" & x).Value = rsibase - 1: modtemp = Round((timedelaytmp + (timedelaytmp * ladjust)), 15): Range("O" & x).Value = format(modtemp, "hh:mm:ss")
1045 If rsicomparetmpc = 6 Then: 'Range("N" & x).Value = rsibase + 1: modtemp = Round((timedelaytmp + (timedelaytmp * ladjust)), 15): Range("O" & x).Value = format(modtemp, "hh:mm:ss")
1046 If rsicomparetmpc = 7 Then: 'Range("N" & x).Value = rsibase - 1: modtemp = Round((timedelaytmp + (timedelaytmp * sadjust)), 15): Range("O" & x).Value = format(modtemp, "hh:mm:ss")
1047 If rsicomparetmpc = 8 Then: 'Range("N" & x).Value = rsibase + 1: modtemp = Round((timedelaytmp + (timedelaytmp * sadjust)), 15): Range("O" & x).Value = format(modtemp, "hh:mm:ss")
1048 If rsicomparetmpc = 9 Then: 'Range("N" & x).Value = rsibase - 1: Range("O" & x).Value = timedelaytmp
1049 If rsicomparetmpc = 10 Then: 'Range("N" & x).Value = rsibase + 1: Range("O" & x).Value = timedelaytmp
1050 End If
1051 End If
1052skiprsi:
1053 'If rsicomparetmpc = 0 Then
1054 If rsicompare(rsicomparetmpc) > 0 Then
1055 If rsicompare(rsicomparetmpc) = 0 Or rsicompare(rsicomparetmpc) = "" Then
1056 Range("AC" & x).Value = 0
1057 End If
1058 Range("AC" & x).Value = Round(rsicompare(rsicomparetmpc), 8)
1059 Range("AB" & x).Value = Round(Range("AB" & x).Value + rsicompare(rsicomparetmpc), 8)
1060 Else
1061 If rsicompare(rsicomparetmpc) = "" Then
1062 rsicompare(rsicomparetmpc) = 0
1063 End If
1064 Range("AD" & x).Value = Round(rsicompare(rsicomparetmpc), 8)
1065 Range("AB" & x).Value = Round(Range("AB" & x).Value + rsicompare(rsicomparetmpc), 8)
1066 End If
1067
1068 For ii = 1 To UBound(compare)
1069 ' Reverse = UBound(compare) - (ii - 1)
1070 If ii = 1 Then
1071 comparetmp = compare(ii)
1072 comparetmpc = ii
1073 End If
1074 If compare(ii) > comparetmp Then
1075 comparetmp = compare(ii)
1076 comparetmpc = ii
1077 ElseIf compare(1) = compare(2) And compare(2) = compare(3) Then
1078 comparetmpc = 0
1079 End If
1080 Next
1081 If Range("R" & x).Value = 0 Then
1082 Else
1083 GoTo skipema
1084 End If
1085 If comparetmpc = 0 Then
1086 modtemp = Round((etimedelaytmp + (etimedelaytmp * ladjust)), 15): Range("M" & x).Value = format(modtemp, "hh:mm:ss")
1087 'ElseIf comparetmpc = 1 Then
1088 'Range("M" & x).Value = Round((etimedelaytmp + (etimedelaytmp * ladjust)), 15)
1089 Else
1090 If comparetmpc > 1 And comparetmpc < 11 Then
1091 Range("M" & x).Value = etimedelaytmp
1092 If comparetmpc = 2 Then modtemp = Round((etimedelaytmp + (etimedelaytmp * ladjust)), 15): Range("M" & x).Value = format(modtemp, "hh:mm:ss"): 'Range("K" & x).Value = semabase - 1
1093 If comparetmpc = 3 Then modtemp = Round((etimedelaytmp + (etimedelaytmp * sadjust)), 15): Range("M" & x).Value = format(modtemp, "hh:mm:ss"): 'Range("K" & x).Value = semabase + 1
1094 If comparetmpc = 4 Then:
1095 If comparetmpc = 5 Then: 'Range("L" & x).Value = lemabase - 1
1096 If comparetmpc = 6 Then: 'Range("L" & x).Value = lemabase + 1
1097 If comparetmpc = 7 Then: 'Range("K" & x).Value = semabase - 1: Range("L" & x).Value = lemabase - 1
1098 If comparetmpc = 8 Then: 'Range("K" & x).Value = semabase - 1: Range("L" & x).Value = lemabase + 1
1099 If comparetmpc = 9 Then: 'Range("K" & x).Value = semabase + 1: Range("L" & x).Value = lemabase - 1
1100 If comparetmpc = 10 Then: 'Range("K" & x).Value = semabase + 1: Range("L" & x).Value = lemabase + 1
1101 End If
1102 If comparetmpc > 10 And comparetmpc < 20 Then
1103 'modtemp = Round((etimedelaytmp + (etimedelaytmp * ladjust)), 15): Range("M" & x).Value = format(modtemp, "hh:mm:ss")
1104 'If comparetmpc = 11Then
1105 If comparetmpc = 12 Then: 'Range("K" & x).Value = semabase - 1
1106 If comparetmpc = 13 Then: 'Range("K" & x).Value = semabase + 1
1107 If comparetmpc = 14 Then: 'Range("L" & x).Value = lemabase - 1
1108 If comparetmpc = 15 Then: 'Range("L" & x).Value = lemabase + 1
1109 If comparetmpc = 16 Then: 'Range("K" & x).Value = semabase - 1: Range("L" & x).Value = lemabase - 1
1110 If comparetmpc = 17 Then: 'Range("K" & x).Value = semabase - 1: Range("L" & x).Value = lemabase + 1
1111 If comparetmpc = 18 Then: 'Range("K" & x).Value = semabase + 1: Range("L" & x).Value = lemabase - 1
1112 If comparetmpc = 19 Then: 'Range("K" & x).Value = semabase + 1: Range("L" & x).Value = lemabase + 1
1113
1114 End If
1115 If comparetmpc > 19 And comparetmpc < 29 Then
1116 'modtemp = Round((etimedelaytmp + (etimedelaytmp * sadjust)), 15): Range("M" & x).Value = format(modtemp, "hh:mm:ss")
1117 'If comparetmpc = 20 Then
1118 If comparetmpc = 21 Then: 'Range("K" & x).Value = semabase - 1
1119 If comparetmpc = 22 Then: 'Range("K" & x).Value = semabase + 1
1120 If comparetmpc = 23 Then: 'Range("L" & x).Value = lemabase - 1
1121 If comparetmpc = 24 Then: 'Range("L" & x).Value = lemabase + 1
1122 If comparetmpc = 25 Then: 'Range("K" & x).Value = semabase - 1: Range("L" & x).Value = lemabase - 1
1123 If comparetmpc = 26 Then: 'Range("K" & x).Value = semabase - 1: Range("L" & x).Value = lemabase + 1
1124 If comparetmpc = 27 Then: 'Range("K" & x).Value = semabase + 1: Range("L" & x).Value = lemabase - 1
1125 If comparetmpc = 28 Then: 'Range("K" & x).Value = semabase + 1: Range("L" & x).Value = lemabase + 1
1126 End If
1127 End If
1128skipema:
1129 'If comparetmpc = 0 Then
1130 If compare(comparetmpc) > 0 Then
1131 If compare(comparetmpc) = 0 Or compare(comparetmpc) = "" Then
1132 Range("AF" & x).Value = 0
1133 End If
1134 Range("AF" & x).Value = compare(comparetmpc)
1135 Range("AE" & x).Value = Range("AE" & x).Value + compare(comparetmpc)
1136 Else
1137 If compare(comparetmpc) = "" Then
1138 compare(comparetmpc) = 0
1139 End If
1140 Range("AG" & x).Value = compare(comparetmpc)
1141 Range("AE" & x).Value = Range("AE" & x).Value + compare(comparetmpc)
1142 End If
1143
1144 sema = semabase
1145 lema = lemabase
1146
1147nextstep:
1148 If fn(0) = "N/A" Then
1149 tmpchq = 0
1150 tmpadva = 0
1151 tmpdecl = 0
1152 tmpavggain = 0
1153 tmpavgloss = 0
1154 tmprs = 0
1155 tmprsi = 0
1156 tmpsema = 0
1157 tmplema = 0
1158 tmp1rtb = 0
1159 tmp2rtb = 0
1160 tmp3rtb = 0
1161 tmpeb = 0
1162 tmp1rts = 0
1163 tmpes = 0
1164 tmpep = 0
1165 tmpextr = 0
1166 en = Array(timestamp, tmpbid, tmpask, tmplast, tmpchq, tmpadva, tmpdecl, tmpavggain, tmpavgloss, tmprs, tmprsi, tmpsema, tmplema, tmp1rtb, tmp2rtb, tmp3rtb, tmpeb, tmp1rts, tmpes, tmpep, tmpextr)
1167 Range("AN" & x).Value = en(0) & "~" & en(1) & "~" & en(2) & "~" & en(3) & "~" & en(4) & "~" & en(5) & "~" & en(6) & "~" & en(7) & "~" & en(8) & "~" & en(9) & "~" & en(10) & "~" & en(11) & "~" & en(12) & "~" & en(13) & "~" & en(14) & "~" & en(15) & "~" & en(16) & "~" & en(17) & "~" & en(18) & "~" & en(19) & "~" & en(20)
1168
1169 Else
1170
1171 Range("AN" & x, "ANA" & x).Copy Range("AO" & x)
1172 Range("AN" & x).Value = histcell(0)(0) & "~" & histcell(0)(1) & "~" & histcell(0)(2) & "~" & histcell(0)(3) & "~" & histcell(0)(4) & "~" & histcell(0)(5) & "~" & histcell(0)(6) & "~" & histcell(0)(7) & "~" & histcell(0)(8) & "~" & histcell(0)(9) & "~" & histcell(0)(10) & "~" & en(11) & "~" & en(12) & "~" & en(13) & "~" & en(14) & "~" & en(15) & "~" & en(16) & "~" & en(17) & "~" & en(18) & "~" & en(19) & "~" & en(20)
1173 If en(10) = 0 Then
1174 Else
1175 If Not en(10) Then
1176 Range("AI" & x).Value = Range("A" & x).Value
1177 'Range("AK" & x).Value = en(8) & ":" & Range("AK" & x).Value
1178 End If
1179
1180 End If
1181 'Range(Cells(x, histstart + periods), Cells(x, 1000)).Clear
1182 End If
1183
1184 Debug.Print Range("A" & x).Value & Chr(32) & "RSI" & Chr(32) & histcell(0)(0) & "~" & histcell(0)(1) & "~" & histcell(0)(2) & "~" & histcell(0)(3) & "~" & histcell(0)(4) & "~" & histcell(0)(5) & "~" & histcell(0)(6) & "~" & histcell(0)(7) & "~" & histcell(0)(8) & "~" & histcell(0)(9) & "~" & histcell(0)(10)
1185 Debug.Print Range("A" & x).Value & Chr(32) & "EMA" & Chr(32) & en(11) & "~" & en(12) & "~" & en(13) & "~" & en(14) & "~" & en(15) & "~" & en(16) & "~" & en(17) & "~" & en(18) & "~" & en(19) & "~" & en(20)
1186
1187 'End If
1188
1189
1190 Erase compare
1191 Erase rsicompare
1192 comparetmpc = 0
1193 rsicomparetmpc = 0
1194 Erase en
1195 Erase fn
1196 Erase ehistcell
1197 sumsema = 0
1198 sumlema = 0
1199 Erase histcell
1200 sumadva = 0
1201 sumdecl = 0
1202 toggleut = 0
1203 togglect = 0
1204 toggledt = 0
1205 eretestut = 0
1206 eretestdt = 0
1207 ecrossut = 0
1208 ecrossut = 0
1209 '"last", "chg", "adva", "decl", "avggain", "avgloss", "rs", "rsi"
1210 'Range("AN" & x).Value = j.getJsonObjectValue("result.Last")
1211
1212
1213
1214 Else
1215 Range("B" & x).Value = 0
1216 End If
1217
1218
1219 End If
1220
1221NextIteration7:
1222 x = x + 1
1223
1224 Application.Wait (Now + TimeValue("0:00:01"))
1225 Next
1226End If
1227
1228 'Application.Wait (Now + TimeValue("0:00:01"))
1229
1230 'If Range("I" & x).Value = 1 Then
1231
1232
1233 Range("D1:AN500").Columns.AutoFit
1234 rdymarkhist = 1
1235 'Else
1236 ' MsgBox "No items found."
1237 'End If
1238 Debug.Print "done!"
1239 Application.OnTime Now + TimeValue("00:00:20"), "ThisWorkbook.GetMyBittrexData"
1240End Sub