This commit is contained in:
2022-07-14 06:14:50 +09:00
parent fecec43e33
commit 3cd6db5831
2 changed files with 11 additions and 37 deletions

View File

@@ -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