Guest User

Untitled

a guest
Jun 20th, 2016
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. from matplotlib import pylab
  2. import time
  3.  
  4.  
  5. column = []
  6. zero = []
  7. cross = []
  8. box = 2
  9. reversal = 3
  10. curtime = round(time.time())
  11. history = [8515,8525,8510,8515,8510,8515,8505,8515,8512,8515,8510,8516,8510,8515,8506,8510,8506,8510,8500,8514,8510,8517,8510,8519,8508,8515,8510,8525,8520,8525,8522,8525,8520,8525,8522,8525,8520,8523,8520,8523,8517,8525,8520,8528,8525,8539,8535,8538,8535,8545,8540,8544,8540,8545,8535,8544,8540,8545,8535,8538,8532,8538,8535,8543,8540,8543,8539,8549,8545,8550,8547,8554,8546,8563,8553,8565,8560,8563,8560,8563,8560,8563,8560,8563,8557,8560,8552,8555,8546,8550,8545,8550,8545,8550,8540,8560,8550,8553,8545,8555,8540,8548,8542,8545,8540,8545,8537,8540,8535,8550,8546,8555,8550,8558,8555,8565,8560,8570,8565,8570,8566,8575,8570,8580,8570,8580,8575,8585,8577,8585]
  12. count = 0
  13. colcount = 0
  14. dir = ''
  15. loop = len(history)-1
  16. curprice = history[count]
  17. if curprice > history[count+1]:
  18. dir = 'down'
  19. else:
  20. dir = 'up'
  21. while count < loop:
  22. nextprice = history[count+1]
  23. if dir == 'up':
  24. if nextprice - curprice > box:
  25. k = nextprice - curprice
  26. while k >= box:
  27. cross.append(curprice+k)
  28. zero.append(8449)
  29. column.append(colcount)
  30. k -= box
  31. curprice = nextprice
  32. if curprice - nextprice > box * reversal:
  33. dir = 'down'
  34. colcount += 1
  35. k = curprice - nextprice
  36. while k >= box:
  37. cross.append(8449)
  38. zero.append(curprice - k)
  39. column.append(colcount)
  40. k -= box
  41. curprice = nextprice
  42. elif dir == 'down':
  43. if curprice - nextprice > box:
  44. k = curprice - nextprice
  45. while k >= box:
  46. cross.append(8449)
  47. zero.append(curprice+k)
  48. column.append(colcount)
  49. k -= box
  50. curprice = nextprice
  51. if nextprice - curprice > box * reversal:
  52. dir = 'up'
  53. colcount += 1
  54. k = nextprice - curprice
  55. while k >= box:
  56. cross.append(curprice - k)
  57. zero.append(8449)
  58. column.append(colcount)
  59. k -= box
  60. curprice = nextprice
  61.  
  62. count += 1
  63. k = len(column)-1
  64. while k > 0:
  65. print column[k],
  66. print cross[k],
  67. print zero[k]
  68. k -=1
  69. print len(column)
  70. print len(cross)
  71. print len(zero)
  72.  
  73. pylab.plot (column, cross, 'g^',label='cross')
  74. pylab.plot (column, zero, 'rv',label='zero')
  75. pylab.grid()
  76. pylab.legend ()
  77. pylab.show()
Advertisement
Add Comment
Please, Sign In to add comment