Skip to content

Latest commit

 

History

History
65 lines (49 loc) · 1.56 KB

五线向上&&突破前高.md

File metadata and controls

65 lines (49 loc) · 1.56 KB

策略名称

五线向上&&突破前高

策略作者

围龙小子

策略描述

均线策略(python版)教学性质,实盘慎用。

源码 (python)

import types
import peakutils
import os
import time
import numpy
def main():
	MA_LINES = ['5_8','5_13','5_21','5_34','8_13','8_21','8_34','13_21','13_34','21_34']
	initAccount = ext.GetAccount()
	reported_price_list = []
	while True:
		lines_up = True
		for lines in MA_LINES:
			data = lines.split('_')
			FastPeriod,SlowPeriod = int(data[0]),int(data[1])
			n = ext.Cross(FastPeriod,SlowPeriod)
			if n <= 0:
				lines_up = False
				break

		if lines_up == True:
			records = exchange.GetRecords(PERIOD_M15)
			current_price = records[-1].get("Close", 0)
			times = [record.get("Time", 0) for record in records]
			y = [record.get("High", 0) for record in records]
			x = [i for i in xrange(1,len(y)+1)]
			x, y = numpy.array(x),numpy.array(y)
			n_peaks = 2
			prepared = y - peakutils.baseline(y, 3)
			idx = peakutils.indexes(prepared, thres=0.03, min_dist=10)
			previous_high = y[sorted(idx.tolist()[:10])[-1]]
			previous_time = int(str(times[idx.tolist()[-1]])[:-3])
			previous_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(previous_time))
			if current_price >= previous_high:
				if previous_high not in reported_price_list:
					Log("五线向上,突破前期:",previous_time,"的高点:",previous_high, "当前价格:",current_price)
					reported_price_list.append(previous_high)

		Sleep(1000)

策略出处

https://www.fmz.com/strategy/76827

更新时间

2018-03-16 12:42:24