Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from matplotlib import pylab
- import time
- column = []
- zero = []
- cross = []
- box = 2
- reversal = 3
- curtime = round(time.time())
- 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]
- count = 0
- colcount = 0
- dir = ''
- loop = len(history)-1
- curprice = history[count]
- if curprice > history[count+1]:
- dir = 'down'
- else:
- dir = 'up'
- while count < loop:
- nextprice = history[count+1]
- if dir == 'up':
- if nextprice - curprice > box:
- k = nextprice - curprice
- while k >= box:
- cross.append(curprice+k)
- zero.append(8449)
- column.append(colcount)
- k -= box
- curprice = nextprice
- if curprice - nextprice > box * reversal:
- dir = 'down'
- colcount += 1
- k = curprice - nextprice
- while k >= box:
- cross.append(8449)
- zero.append(curprice - k)
- column.append(colcount)
- k -= box
- curprice = nextprice
- elif dir == 'down':
- if curprice - nextprice > box:
- k = curprice - nextprice
- while k >= box:
- cross.append(8449)
- zero.append(curprice+k)
- column.append(colcount)
- k -= box
- curprice = nextprice
- if nextprice - curprice > box * reversal:
- dir = 'up'
- colcount += 1
- k = nextprice - curprice
- while k >= box:
- cross.append(curprice - k)
- zero.append(8449)
- column.append(colcount)
- k -= box
- curprice = nextprice
- count += 1
- k = len(column)-1
- while k > 0:
- print column[k],
- print cross[k],
- print zero[k]
- k -=1
- print len(column)
- print len(cross)
- print len(zero)
- pylab.plot (column, cross, 'g^',label='cross')
- pylab.plot (column, zero, 'rv',label='zero')
- pylab.grid()
- pylab.legend ()
- pylab.show()
Advertisement
Add Comment
Please, Sign In to add comment