update
This commit is contained in:
@@ -37,28 +37,20 @@ class WMA:
|
||||
|
||||
|
||||
class MA_Cross:
|
||||
def __init__(self, ma, unit, width):
|
||||
def __init__(self, ma, unit):
|
||||
self._ma = ma
|
||||
self._unit = unit
|
||||
self._width = width
|
||||
|
||||
self._period_short = 5
|
||||
self._period_mid = 21
|
||||
self._period_long = 55
|
||||
|
||||
self._posi_amp = 0.1
|
||||
self._period_short = 21
|
||||
self._period_mid = 55
|
||||
|
||||
def judge(self, status):
|
||||
cands = status.candles[self._unit]
|
||||
short = self._ma.calc(cands, self._period_short)
|
||||
mid = self._ma.calc(cands, self._period_mid)
|
||||
long = self._ma.calc(cands, self._period_long)
|
||||
|
||||
width = mid * self._width
|
||||
posi = max(-1, min((short-long)/(2.5*width), 1)) * self._posi_amp
|
||||
|
||||
diff = short - mid
|
||||
if diff < 0:
|
||||
return max(-1, diff/width+posi) # sell
|
||||
return -1 # sell
|
||||
else:
|
||||
return min(1, diff/width+posi) # buy
|
||||
return 1 # buy
|
||||
|
Reference in New Issue
Block a user