# 狙い: 親より閾値を緩めて取引数を増やす(seg1の3回は少ない)
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
fr = b.get('fr', 0)
if fr > 0.0003:
return 0
th = 0.0028 if fr >= 0 else 0.002
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
sma20 = sum(c[-20:]) / 20
if c[-1] < sma20 * (1 - th) and b['l'] <= sum(x['l'] for x in window[-60:]) / 60:
return 1
return 0
# 狙い: 分岐を削除
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
if b.get('fr', 0) > 0.0003:
return 0
elif window[-1]['dw'] < window[-1]['c'] / max(min((_x['l'] for _x in window[-3:])), 1e-09) and sum((_x['c'] * _x['v'] for _x in window[-20:])) / max(sum((_x['v'] for _x in window[-20:])), 1e-09) > sum((_x['h'] for _x in window[-120:])) / 120:
return -1
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 条件を厳しく/緩く
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
if b.get('fr', 0) > 0.0003:
return 0
elif window[-1]['dw'] < window[-1]['c'] / max(min((_x['l'] for _x in window[-3:])), 1e-09) and sum((_x['c'] * _x['v'] for _x in window[-20:])) / max(sum((_x['v'] for _x in window[-20:])), 1e-09) > sum((_x['h'] for _x in window[-120:])) / 120:
return -1
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: else分岐を追加
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
if b.get('fr', 0) > 0.0003:
return 0
elif window[-1]['dw'] < window[-1]['c'] / max(min((_x['l'] for _x in window[-3:])), 1e-09) and sum((_x['c'] * _x['v'] for _x in window[-20:])) / max(sum((_x['v'] for _x in window[-20:])), 1e-09) > sum((_x['h'] for _x in window[-120:])) / 120:
return -1
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
elif sum((_x['c'] * _x['v'] for _x in window[-14:])) / max(sum((_x['v'] for _x in window[-14:])), 1e-09) > sum((_x['l'] for _x in window[-5:])) / 5 * 1.0029:
return 1
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 条件を厳しく/緩く
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1] and window[-1].get('ts', 0.0) / max(sum((_x.get('ts', 0.0) for _x in window[-8:])) / 8, 1e-09) < window[-1]['c'] / max(sum((_x['c'] for _x in window[-30:])) / 30, 1e-09):
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
if b.get('fr', 0) > 0.0003:
return 0
elif window[-1]['dw'] < window[-1]['c'] / max(min((_x['l'] for _x in window[-3:])), 1e-09) and sum((_x['c'] * _x['v'] for _x in window[-20:])) / max(sum((_x['v'] for _x in window[-20:])), 1e-09) > sum((_x['h'] for _x in window[-120:])) / 120:
return -1
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 入れ子を深く
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
if b.get('fr', 0) > 0.0003:
return 0
elif window[-1]['dw'] < window[-1]['c'] / max(min((_x['l'] for _x in window[-3:])), 1e-09) and sum((_x['c'] * _x['v'] for _x in window[-20:])) / max(sum((_x['v'] for _x in window[-20:])), 1e-09) > sum((_x['h'] for _x in window[-120:])) / 120:
return -1
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
if (window[-1]['h'] - max(window[-1]['c'], window[-1]['o'])) / max(window[-1]['h'] - window[-1]['l'], 1e-09) > window[-1]['c'] / max(sum((_x['c'] for _x in window[-5:])) / 5, 1e-09) * 0.9351:
return -1
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 執行スタイル切替(taker成行 ⇔ maker指値)
def signal(window, state):
_exec = 'taker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
if b.get('fr', 0) > 0.0003:
return 0
elif window[-1]['dw'] < window[-1]['c'] / max(min((_x['l'] for _x in window[-3:])), 1e-09) and sum((_x['c'] * _x['v'] for _x in window[-20:])) / max(sum((_x['v'] for _x in window[-20:])), 1e-09) > sum((_x['h'] for _x in window[-120:])) / 120:
return -1
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
if (window[-1]['h'] - max(window[-1]['c'], window[-1]['o'])) / max(window[-1]['h'] - window[-1]['l'], 1e-09) > window[-1]['c'] / max(sum((_x['c'] for _x in window[-5:])) / 5, 1e-09) * 0.9351:
return -1
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 分岐を追加
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
state['ref'] = state.get('ref') or window[-1]['c']
if window[-1]['c'] < state['ref'] * 0.9646:
state['ref'] = window[-1]['c']
return -1
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
if c[-1] >= max((x['h'] for x in window[-60:])):
return -1
return 0
if b.get('fr', 0) > 0.0003:
return 0
if b.get('t1', 0) < -0.15:
return 0
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - 0.003333) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
if sum((_x.get('tb', 0.0) for _x in window[-10:])) / max(sum((_x.get('ts', 0.0) for _x in window[-10:])), 1e-09) <= window[-1].get('ta', 0.0) / max(sum((_x.get('ta', 0.0) for _x in window[-120:])) / 120, 1e-09):
return 1
return 0
# 狙い: 入れ子を深く
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
state['ref'] = state.get('ref') or window[-1]['c']
if window[-1]['c'] < state['ref'] * 0.9646:
state['ref'] = window[-1]['c']
return -1
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
if c[-1] >= max((x['h'] for x in window[-60:])):
return -1
return 0
if b.get('fr', 0) > 0.0003:
return 0
if b.get('t1', 0) < -0.15:
return 0
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
if max((_x['h'] for _x in window[-20:])) < sum((_x['l'] for _x in window[-90:])) / 90:
return 0
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - 0.003333) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
if sum((_x.get('tb', 0.0) for _x in window[-10:])) / max(sum((_x.get('ts', 0.0) for _x in window[-10:])), 1e-09) <= window[-1].get('ta', 0.0) / max(sum((_x.get('ta', 0.0) for _x in window[-120:])) / 120, 1e-09):
return 1
return 0
# 狙い: 分岐を削除
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
state['ref'] = state.get('ref') or window[-1]['c']
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
if c[-1] >= max((x['h'] for x in window[-60:])):
return -1
return 0
if b.get('fr', 0) > 0.0003:
return 0
if b.get('t1', 0) < -0.15:
return 0
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - 0.003333) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
if sum((_x.get('tb', 0.0) for _x in window[-10:])) / max(sum((_x.get('ts', 0.0) for _x in window[-10:])), 1e-09) <= window[-1].get('ta', 0.0) / max(sum((_x.get('ta', 0.0) for _x in window[-120:])) / 120, 1e-09):
return 1
return 0
# 狙い: 条件を厳しく/緩く
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1 and (window[-1].get('ts', 0.0) / max(sum((_x.get('ts', 0.0) for _x in window[-10:])) / 10, 1e-09) < u or window[-1].get('fx', 0.0) / max(sum((_x.get('fx', 0.0) for _x in window[-120:])) / 120, 1e-09) > (window[-1]['h'] - max(window[-1]['c'], window[-1]['o'])) / max(window[-1]['h'] - window[-1]['l'], 1e-09)):
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 条件を厳しく/緩く
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1 or (min(window[-1]['c'], window[-1]['o']) - window[-1]['l']) / max(window[-1]['h'] - window[-1]['l'], 1e-09) >= sum((_x.get('tb', 0.0) for _x in window[-14:])) / max(sum((_x.get('ts', 0.0) for _x in window[-14:])), 1e-09) * 0.9104:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: else分岐を追加
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
if c[-1] >= max((x['h'] for x in window[-60:])):
return -1
elif sum((_x['c'] for _x in window[-5:])) / 5 <= window[-1]['l'] and sum((_x['l'] for _x in window[-60:])) / 60 > sum((_x['h'] for _x in window[-45:])) / 45:
return -1
return 0
if b.get('fr', 0) > 0.0003:
return 0
if b.get('t1', 0) < -0.15:
return 0
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0 and sum((abs(window[-i]['c'] / max(window[-i - 1]['c'], 1e-09) - 1) for i in range(1, 120))) / 120 < window[-1]['dw']:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - 0.003333) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: マイナス資金調達(踏み上げ燃料)で押し目条件を緩めて頻度を上げる
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
if c[-1] >= max(x['h'] for x in window[-60:]):
return -1
return 0
if b.get('fr', 0) > 0.0003 or b.get('t1', 0) < -0.15:
return 0
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
pu = window[-6].get('u', 0)
thr = 0.0025 if b.get('fr', 0) < 0 else 0.004
if u > 0 and pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - thr) and b['l'] <= sum(x['l'] for x in window[-60:]) / 60:
return 1
return 0
# 狙い: 踏み上げ燃料(fr<0)時は浅め、それ以外は深い押し目のみで厳格化
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max(x['h'] for x in window[-60:]) else 0
fr = b.get('fr', 0)
if fr > 0.0001:
return 0
th = 0.002 if fr < 0 else 0.0045
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum(x['l'] for x in window[-60:]) / 60:
return 1
return 0
# 狙い: 条件を厳しく/緩く
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
if b.get('fr', 0) < 0:
if (max((_x['h'] for _x in window[-5:])) > window[-1]['l'] or window[-1]['o'] > sum((_x['h'] for _x in window[-45:])) / 45) and (window[-1]['v'] / max(sum((_x['v'] for _x in window[-3:])) / 3, 1e-09) < sum((_x['h'] - _x['l'] for _x in window[-20:])) / max(sum((_x['v'] for _x in window[-20:])), 1e-09) / max(sum((_x['h'] - _x['l'] for _x in window[-45:])) / max(sum((_x['v'] for _x in window[-45:])), 1e-09), 1e-09) * 1.0949 or window[-1]['h'] < min((_x['l'] for _x in window[-10:]))):
return -1
th = 0.0025
if b.get('fr', 0) > 0.0003:
return 0
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 分岐を削除
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
if b.get('fr', 0) > 0.0003:
return 0
elif window[-1]['dw'] < window[-1]['c'] / max(min((_x['l'] for _x in window[-3:])), 1e-09) and sum((_x['c'] * _x['v'] for _x in window[-20:])) / max(sum((_x['v'] for _x in window[-20:])), 1e-09) > sum((_x['h'] for _x in window[-120:])) / 120:
return -1
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 執行スタイル切替(taker成行 ⇔ maker指値)
def signal(window, state):
_exec = 'taker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
state['ref'] = state.get('ref') or window[-1]['c']
if window[-1]['c'] < state['ref'] * 0.9646:
state['ref'] = window[-1]['c']
return -1
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
if c[-1] >= max((x['h'] for x in window[-60:])):
return -1
return 0
if b.get('fr', 0) > 0.0003:
return 0
if b.get('t1', 0) < -0.15:
return 0
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - 0.003333) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
if sum((_x.get('tb', 0.0) for _x in window[-10:])) / max(sum((_x.get('ts', 0.0) for _x in window[-10:])), 1e-09) <= window[-1].get('ta', 0.0) / max(sum((_x.get('ta', 0.0) for _x in window[-120:])) / 120, 1e-09):
return 1
return 0
# 狙い: else分岐を追加
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834 and (not (window[-1].get('ta', 0.0) / max(sum((_x.get('ta', 0.0) for _x in window[-45:])) / 45, 1e-09) <= window[-1].get('u', 1.0) / max(window[-120].get('u', 1.0), 1e-09) * 0.9449 or max((_x['h'] for _x in window[-30:])) > sum((_x['c'] * _x['v'] for _x in window[-45:])) / max(sum((_x['v'] for _x in window[-45:])), 1e-09))):
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
if b.get('fr', 0) > 0.0003 or b.get('t1', 0) < -0.15 or b.get('fg', 50) > 80:
return 0
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
elif window[-1]['v'] / max(sum((_x['v'] for _x in window[-120:])) / 120, 1e-09) >= u * 1.0927 and sum((_x['h'] - _x['l'] for _x in window[-30:])) / 30 <= window[-1]['c'] * 1.0914:
return 1
if c[-1] < sma20 * (1 - 0.0025) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 分岐を削除
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), window[-1]['c'])
if window[-1]['c'] < state.get('peak', 0.0) * 0.9834:
state['peak'] = 0.0
return -1
if c[-1] / c[-31] - 1 < -0.0012:
if c[-1] >= max((x['h'] for x in window[-60:])):
return -1
return 0
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
lead_ok = u <= 0 or True
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
lead_ok = False
if lead_ok and c[-1] < sma20 * (1 - 0.003333) and (window[-1]['l'] <= sum((x['l'] for x in window[-60:])) / 60):
return 1
return 0
# 狙い: 親の閾値を緩めて取引数を増やす(seg1の取引1回を改善)
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max(x['h'] for x in window[-60:]) else 0
fr = b.get('fr', 0)
if fr > 0.0003:
return 0
th = 0.0025
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum(x['l'] for x in window[-60:]) / 60:
return 1
return 0
# 狙い: 親ロジックをmaker指値化して往復コスト削減(リベート)
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0012:
if b['c'] >= max(x['h'] for x in window[-60:]):
return -1
return 0
sma20 = sum(c[-20:]) / 20
if c[-1] < sma20 * (1 - 0.003333) and max(x['h'] for x in window[-45:]) > b['h'] * 1.0044:
if b['l'] <= sum(x['l'] for x in window[-60:]) / 60:
return 1
return -1
if sum(x['h'] for x in window[-45:]) / 45 <= sum(x['h'] for x in window[-8:]) / 8:
return -1
return 0
# 狙い: 交叉後に変異(組み替えたうえで定数と演算子を揺らす)
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
v1 = c
if c[-1] / c[-31] - 1 < -0.0012:
return 0
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
lead_ok = u <= 0 or True
if u > 0:
if window[-1]['c'] / max(sum((_x['c'] for _x in window[-3:])) / 3, 1e-09) < abs(window[-1]['c'] - window[-1]['o']) / max(window[-1]['h'] - window[-1]['l'], 1e-09):
return 0
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
lead_ok = False
sma20 = sum(c[-20:]) / 20
sma60 = sum(c[-60:]) / 60
if c[-1] < sma20 * (1 - 0.003333) and max((x['h'] for x in window[-45:])) > b['h'] * 1.0044:
if b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return -1
if sum((x['h'] for x in window[-45:])) / 45 <= sum((x['h'] for x in window[-8:])) / 8:
return -1
return 0
# 狙い: else分岐を追加
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
if b.get('fr', 0) > 0.0003:
return 0
elif window[-1]['dw'] < window[-1]['c'] / max(min((_x['l'] for _x in window[-3:])), 1e-09):
return -1
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 条件を厳しく/緩く
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
if b.get('fr', 0) > 0.0003:
return 0
elif window[-1]['dw'] < window[-1]['c'] / max(min((_x['l'] for _x in window[-3:])), 1e-09) and sum((_x['c'] * _x['v'] for _x in window[-20:])) / max(sum((_x['v'] for _x in window[-20:])), 1e-09) > sum((_x['h'] for _x in window[-120:])) / 120 and (sum((_x['c'] for _x in window[-90:])) / 90 < window[-1]['o'] and (sum((abs(window[-i]['c'] / max(window[-i - 1]['c'], 1e-09) - 1) for i in range(1, 45))) / 45 < th * 1.0758 or window[-1]['hh'] > c)):
return -1
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 90本の長めの下落ガードを追加し逆選択をさらに回避
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
if c[-1] / c[-91] - 1 < -0.004:
return 0
fr = b.get('fr', 0)
if fr > 0.0003:
return 0
th = 0.0033 if fr >= 0 else 0.0025
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
sma20 = sum(c[-20:]) / 20
if c[-1] < sma20 * (1 - th) and b['l'] <= sum(x['l'] for x in window[-60:]) / 60:
return 1
return 0
# 狙い: 分岐を削除
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
fr = b.get('fr', 0)
if fr > 0.0003:
return 0
th = 0.0033 if fr >= 0 else 0.0025
u = b.get('u', 0)
if u > 0 and window[-1]['c'] / max(window[-90]['c'], 1e-09) < window[-1]['hh']:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
sma20 = sum(c[-20:]) / 20
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
if sum((_x.get('fr', 0.0) for _x in window[-8:])) / 8 < window[-1].get('fx', 0.0) / max(sum((_x.get('fx', 0.0) for _x in window[-3:])) / 3, 1e-09):
return -1
return 0
# 狙い: 分岐を追加
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0016:
return -1
u = [x['u'] for x in window]
if u[-1] <= 0 or u[-6] <= 0:
return 0
need = 0.002
gap = u[-1] / u[-6] - 1 - (c[-1] / c[-6] - 1)
if gap > need:
return 1
if window[-1]['c'] >= window[-1]['o']:
return -1
return 0
# 狙い: 執行スタイル切替(taker成行 ⇔ maker指値)
def signal(window, state):
_exec = 'taker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0016:
return -1
u = [x['u'] for x in window]
if u[-1] <= 0 or u[-6] <= 0:
return 0
need = 0.002
gap = u[-1] / u[-6] - 1 - (c[-1] / c[-6] - 1)
if gap > need:
return 1
if gap < -need * 0.25:
return -1
return 0
# 狙い: 執行スタイル切替(taker成行 ⇔ maker指値)
def signal(window, state):
_exec = 'taker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0016:
return -1
u = [x['u'] for x in window]
if u[-1] <= 0 or u[-6] <= 0:
return 0
need = 0.002
gap = u[-1] / u[-6] - 1 - (c[-1] / c[-6] - 1)
if gap > need:
return 1
if window[-1]['c'] >= window[-1]['o']:
return -1
return 0
# 狙い: 分岐を削除
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0016:
return -1
u = [x['u'] for x in window]
if u[-1] <= 0 or u[-6] <= 0:
return 0
need = 0.002
gap = u[-1] / u[-6] - 1 - (c[-1] / c[-6] - 1)
if gap > need:
return 1
if window[-1]['dw'] >= window[-1]['o'] / max(window[-2]['c'], 1e-09) * 0.902:
return -1
return 0
# 狙い: 執行スタイル切替(taker成行 ⇔ maker指値)
def signal(window, state):
_exec = 'taker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0016:
return -1
u = [x['u'] for x in window]
if u[-1] <= 0 or u[-6] <= 0:
return 0
need = 0.002
gap = u[-1] / u[-6] - 1 - (c[-1] / c[-6] - 1)
if gap > need:
return 1
if window[-1]['dw'] >= window[-1]['o'] / max(window[-2]['c'], 1e-09) * 0.902:
return -1
return 0
# 狙い: else分岐を追加
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0016:
return -1
elif window[-1]['o'] > sum((_x['c'] for _x in window[-8:])) / 8:
return -1
u = [x['u'] for x in window]
if u[-1] <= 0 or u[-6] <= 0:
return 0
need = 0.002
gap = u[-1] / u[-6] - 1 - (c[-1] / c[-6] - 1)
if gap > need:
return 1
if gap < -need * 0.25:
return -1
return 0
# 狙い: 入れ子を深く(returnを条件で分ける)
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0016:
return -1
u = [x['u'] for x in window]
if u[-1] <= 0 or u[-6] <= 0:
return 0
need = 0.002
gap = u[-1] / u[-6] - 1 - (c[-1] / c[-6] - 1)
if gap > need:
return 1
if gap < -need * 0.25:
if need >= sum((1 for _x in window[-3:] if _x['c'] > _x['o'])) / 3:
return -1
else:
return 0
return 0
# 狙い: 分岐を追加
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0016:
return -1
u = [x['u'] for x in window]
if u[-1] <= 0 or u[-6] <= 0:
return 0
need = 0.002
gap = u[-1] / u[-6] - 1 - (c[-1] / c[-6] - 1)
if gap > need:
return 1
if gap < -need * 0.25:
return -1
if need > window[-1]['dw'] * 0.9411:
return -1
return 0
# 狙い: 執行スタイル切替(taker成行 ⇔ maker指値)
def signal(window, state):
_exec = 'taker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0016:
return -1
u = [x['u'] for x in window]
if u[-1] <= 0 or u[-6] <= 0:
return 0
need = 0.002
gap = u[-1] / u[-6] - 1 - (c[-1] / c[-6] - 1)
if gap > need:
return 1
if gap < -need * 0.25:
return -1
if not window[-1]['l'] > window[-1]['c']:
return -1
return 0
# 狙い: 分岐を追加
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0016:
return -1
u = [x['u'] for x in window]
if u[-1] <= 0 or u[-6] <= 0:
return 0
need = 0.002
gap = u[-1] / u[-6] - 1 - (c[-1] / c[-6] - 1)
if gap > need:
return 1
if gap < -need * 0.25:
return -1
if not window[-1]['l'] > window[-1]['c']:
return -1
return 0
# 狙い: 分岐を追加
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0016:
return -1
u = [x['u'] for x in window]
if u[-1] <= 0 or u[-6] <= 0:
return 0
need = 0.002
gap = u[-1] / u[-6] - 1 - (c[-1] / c[-6] - 1)
if gap > need:
return 1
if gap < -need * 0.25:
return -1
if window[-1]['dw'] >= window[-1]['o'] / max(window[-2]['c'], 1e-09) * 0.902:
return -1
return 0
# 狙い: 執行スタイル切替(taker成行 ⇔ maker指値)
def signal(window, state):
_exec = 'taker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0016:
return -1
u = [x['u'] for x in window]
if u[-1] <= 0 or u[-6] <= 0:
return 0
need = 0.002
gap = u[-1] / u[-6] - 1 - (c[-1] / c[-6] - 1)
if gap > need:
return 1
if gap < -need * 0.25:
return -1
if window[-1]['dw'] >= window[-1]['o'] / max(window[-2]['c'], 1e-09) * 0.902:
return -1
return 0
# 狙い: 分岐を削除
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0016 or sum((_x['l'] for _x in window[-30:])) / 30 >= window[-1]['l']:
return -1
u = [x['u'] for x in window]
if u[-1] <= 0 or u[-6] <= 0:
return 0
need = 0.002
gap = u[-1] / u[-6] - 1 - (c[-1] / c[-6] - 1)
if gap > need:
return 1
return 0
# 狙い: 分岐を追加
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0016:
return -1
u = [x['u'] for x in window]
if u[-1] <= 0 or u[-6] <= 0:
return 0
need = 0.002
gap = u[-1] / u[-6] - 1 - (c[-1] / c[-6] - 1)
if gap > need:
return 1
if gap < -need * 0.25:
return -1
if sum((_x['h'] - _x['l'] for _x in window[-8:])) / 8 < sum((_x['c'] for _x in window[-90:])) / 90 * 1.0508:
return -1
return 0
# 狙い: 分岐を削除
def signal(window, state):
_exec = 'maker'
closes = [b['c'] for b in window]
def ema(vals, n):
k = 2 / (n + 1)
e = vals[0]
for v in vals[1:]:
e = v * k + e * (1 - k)
return e
e_fast = ema(closes[-120:], 30)
e_slow = ema(closes[-120:], 90)
if closes[-1] < min(e_fast, e_slow) * 0.993:
return 1
return 0
# 狙い: else分岐を追加
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
if b.get('fr', 0) > 0.0003:
return 0
elif window[-1]['dw'] < window[-1]['c'] / max(min((_x['l'] for _x in window[-3:])), 1e-09) and sum((_x['c'] * _x['v'] for _x in window[-20:])) / max(sum((_x['v'] for _x in window[-20:])), 1e-09) > sum((_x['h'] for _x in window[-120:])) / 120:
return -1
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
elif sum((_x['c'] * _x['v'] for _x in window[-14:])) / max(sum((_x['v'] for _x in window[-14:])), 1e-09) > sum((_x['l'] for _x in window[-5:])) / 5 * 1.0029:
return 1
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 親より閾値を緩めて取引数を増やす(seg1の3回は少ない)
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
fr = b.get('fr', 0)
if fr > 0.0003:
return 0
th = 0.0028 if fr >= 0 else 0.002
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
sma20 = sum(c[-20:]) / 20
if c[-1] < sma20 * (1 - th) and b['l'] <= sum(x['l'] for x in window[-60:]) / 60:
return 1
return 0
# 狙い: 条件を厳しく/緩く
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834 and (not (window[-1].get('ta', 0.0) / max(sum((_x.get('ta', 0.0) for _x in window[-45:])) / 45, 1e-09) <= window[-1].get('u', 1.0) / max(window[-120].get('u', 1.0), 1e-09) * 0.9449 or max((_x['h'] for _x in window[-30:])) > sum((_x['c'] * _x['v'] for _x in window[-45:])) / max(sum((_x['v'] for _x in window[-45:])), 1e-09))):
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
if b.get('fr', 0) > 0.0003 or b.get('t1', 0) < -0.15 or b.get('fg', 50) > 80:
return 0
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - 0.0025) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 親より浅い押しで頻度を増やし、強欲過熱(fg高)時は見送る
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0012:
if c[-1] >= max((x['h'] for x in window[-60:])):
return -1
return 0
if b.get('t1', 0) < -0.15 or b.get('fr', 0) > 0.0004:
return 0
if b.get('fg', 50) > 80:
return 0
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - 0.0028) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 条件を厳しく/緩く
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0012:
if window[-1]['c'] >= max((_x['h'] for _x in window[-60:])):
return -1
else:
return 0
sma20 = sum(c[-20:]) / 20
sma60 = sum(c[-60:]) / 60
need = 0.003333
if c[-1] < sma20 * (1 - need) and window[-1]['c'] / max(sum((_x['c'] for _x in window[-90:])) / 90, 1e-09) <= window[-1]['c'] / max(min((_x['l'] for _x in window[-10:])), 1e-09):
return 1
if c[-1] > sma20 * (1 + need) and window[-1].get('tb', 0.0) / max(sum((_x.get('tb', 0.0) for _x in window[-45:])) / 45, 1e-09) <= (window[-1].get('oi', 1.0) / max(window[-8].get('oi', 1.0), 1e-09) - 1) * (window[-1]['c'] / max(window[-8]['c'], 1e-09) - 1):
return -1
if sum((_x['h'] for _x in window[-10:])) / 10 > sum((_x['c'] * _x['v'] for _x in window[-10:])) / max(sum((_x['v'] for _x in window[-10:])), 1e-09) * 1.0608 or sum((_x['h'] for _x in window[-14:])) / 14 < sum((_x['c'] for _x in window[-10:])) / 10:
return -1
if (window[-1].get('tb', 0.0) / max(sum((_x.get('tb', 0.0) for _x in window[-14:])) / 14, 1e-09) <= window[-1].get('ta', 0.0) / max(sum((_x.get('ta', 0.0) for _x in window[-60:])) / 60, 1e-09) or sum((_x['l'] for _x in window[-45:])) / 45 > window[-1]['l']) and (not (window[-1]['l'] < min((_x['l'] for _x in window[-5:])) or sum((_x['h'] for _x in window[-14:])) / 14 < sum((_x['h'] for _x in window[-90:])) / 90)):
return -1
return 0
# 狙い: 執行スタイル切替(taker成行 ⇔ maker指値)
def signal(window, state):
_exec = 'taker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0012:
if window[-1]['c'] >= max((_x['h'] for _x in window[-60:])):
return -1
else:
return 0
sma20 = sum(c[-20:]) / 20
sma60 = sum(c[-60:]) / 60
need = 0.003333
if c[-1] < sma20 * (1 - need) and window[-1]['c'] / max(sum((_x['c'] for _x in window[-90:])) / 90, 1e-09) <= window[-1]['c'] / max(min((_x['l'] for _x in window[-10:])), 1e-09):
return 1
if c[-1] > sma20 * (1 + need) and window[-1].get('tb', 0.0) / max(sum((_x.get('tb', 0.0) for _x in window[-45:])) / 45, 1e-09) <= (window[-1].get('oi', 1.0) / max(window[-8].get('oi', 1.0), 1e-09) - 1) * (window[-1]['c'] / max(window[-8]['c'], 1e-09) - 1):
return -1
if sum((_x['h'] for _x in window[-10:])) / 10 > sum((_x['c'] * _x['v'] for _x in window[-10:])) / max(sum((_x['v'] for _x in window[-10:])), 1e-09) * 1.0608 or sum((_x['h'] for _x in window[-14:])) / 14 < sum((_x['c'] for _x in window[-10:])) / 10:
return -1
if (window[-1].get('tb', 0.0) / max(sum((_x.get('tb', 0.0) for _x in window[-14:])) / 14, 1e-09) <= window[-1].get('ta', 0.0) / max(sum((_x.get('ta', 0.0) for _x in window[-60:])) / 60, 1e-09) or sum((_x['l'] for _x in window[-45:])) / 45 > window[-1]['l']) and (not (window[-1]['l'] < min((_x['l'] for _x in window[-5:])) or sum((_x['h'] for _x in window[-14:])) / 14 < sum((_x['h'] for _x in window[-90:])) / 90)):
return -1
return 0
# 狙い: 分岐を削除
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
if b.get('fr', 0) > 0.0003:
return 0
elif window[-1]['dw'] < window[-1]['c'] / max(min((_x['l'] for _x in window[-3:])), 1e-09) and sum((_x['c'] * _x['v'] for _x in window[-20:])) / max(sum((_x['v'] for _x in window[-20:])), 1e-09) > sum((_x['h'] for _x in window[-120:])) / 120:
return -1
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 分岐を削除
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
if b.get('fr', 0) > 0.0003:
return 0
elif window[-1]['dw'] < window[-1]['c'] / max(min((_x['l'] for _x in window[-3:])), 1e-09) and sum((_x['c'] * _x['v'] for _x in window[-20:])) / max(sum((_x['v'] for _x in window[-20:])), 1e-09) > sum((_x['h'] for _x in window[-120:])) / 120:
return -1
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 条件を厳しく/緩く
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
if c[-1] >= max((x['h'] for x in window[-60:])):
return -1
return 0
if b.get('fr', 0) > 0.0003:
return 0
if b.get('t1', 0) < -0.15:
return 0
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0 and sum((abs(window[-i]['c'] / max(window[-i - 1]['c'], 1e-09) - 1) for i in range(1, 120))) / 120 < window[-1]['dw']:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - 0.003333) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: else分岐を追加
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
if c[-1] >= max((x['h'] for x in window[-60:])):
return -1
elif sum((_x['c'] for _x in window[-5:])) / 5 <= window[-1]['l'] and sum((_x['l'] for _x in window[-60:])) / 60 > sum((_x['h'] for _x in window[-45:])) / 45:
return -1
return 0
if b.get('fr', 0) > 0.0003:
return 0
if b.get('t1', 0) < -0.15:
return 0
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0 and sum((abs(window[-i]['c'] / max(window[-i - 1]['c'], 1e-09) - 1) for i in range(1, 120))) / 120 < window[-1]['dw']:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - 0.003333) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 分岐を削除
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
fr = b.get('fr', 0)
if fr > 0.0003:
return 0
th = 0.0033 if fr >= 0 else 0.0025
u = b.get('u', 0)
if u > 0 and window[-1]['c'] / max(window[-90]['c'], 1e-09) < window[-1]['hh']:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
sma20 = sum(c[-20:]) / 20
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
if sum((_x.get('fr', 0.0) for _x in window[-8:])) / 8 < window[-1].get('fx', 0.0) / max(sum((_x.get('fx', 0.0) for _x in window[-3:])) / 3, 1e-09):
return -1
return 0
# 狙い: 親ロジックをmaker指値化して往復コスト削減(リベート)
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] / c[-31] - 1 < -0.0012:
if b['c'] >= max(x['h'] for x in window[-60:]):
return -1
return 0
sma20 = sum(c[-20:]) / 20
if c[-1] < sma20 * (1 - 0.003333) and max(x['h'] for x in window[-45:]) > b['h'] * 1.0044:
if b['l'] <= sum(x['l'] for x in window[-60:]) / 60:
return 1
return -1
if sum(x['h'] for x in window[-45:]) / 45 <= sum(x['h'] for x in window[-8:]) / 8:
return -1
return 0
# 狙い: 交叉後に変異(組み替えたうえで定数と演算子を揺らす)
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
v1 = c
if c[-1] / c[-31] - 1 < -0.0012:
return 0
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
lead_ok = u <= 0 or True
if u > 0:
if window[-1]['c'] / max(sum((_x['c'] for _x in window[-3:])) / 3, 1e-09) < abs(window[-1]['c'] - window[-1]['o']) / max(window[-1]['h'] - window[-1]['l'], 1e-09):
return 0
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
lead_ok = False
sma20 = sum(c[-20:]) / 20
sma60 = sum(c[-60:]) / 60
if c[-1] < sma20 * (1 - 0.003333) and max((x['h'] for x in window[-45:])) > b['h'] * 1.0044:
if b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return -1
if sum((x['h'] for x in window[-45:])) / 45 <= sum((x['h'] for x in window[-8:])) / 8:
return -1
return 0
# 狙い: 分岐を追加
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
fr = b.get('fr', 0)
if fr > 0.0003:
return 0
th = 0.0033 if fr >= 0 else 0.0025
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
sma20 = sum(c[-20:]) / 20
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
if sum((_x.get('fr', 0.0) for _x in window[-8:])) / 8 < window[-1].get('fx', 0.0) / max(sum((_x.get('fx', 0.0) for _x in window[-3:])) / 3, 1e-09):
return -1
if window[-1]['h'] < sum((_x['c'] for _x in window[-3:])) / 3:
return -1
return 0
# 狙い: else分岐を追加
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
fr = b.get('fr', 0)
if fr > 0.0003:
return 0
th = 0.0033 if fr >= 0 else 0.0025
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
sma20 = sum(c[-20:]) / 20
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
elif sum((_x.get('tb', 0.0) for _x in window[-14:])) / max(sum((_x.get('ts', 0.0) for _x in window[-14:])), 1e-09) <= window[-1].get('fr', 0.0) * 1.0936:
return 1
return 0
# 狙い: 分岐を削除
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
fr = b.get('fr', 0)
if fr > 0.0003:
return 0
th = 0.0033 if fr >= 0 else 0.0025
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
sma20 = sum(c[-20:]) / 20
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
if sum((_x.get('fr', 0.0) for _x in window[-8:])) / 8 < window[-1].get('fx', 0.0) / max(sum((_x.get('fx', 0.0) for _x in window[-3:])) / 3, 1e-09):
return -1
return 0
# 狙い: 親の閾値を緩めて取引数を増やす(seg1の取引1回を改善)
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max(x['h'] for x in window[-60:]) else 0
fr = b.get('fr', 0)
if fr > 0.0003:
return 0
th = 0.0025
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum(x['l'] for x in window[-60:]) / 60:
return 1
return 0
# 狙い: 条件を厳しく/緩く
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
if b.get('fr', 0) > 0.0003:
return 0
elif window[-1]['dw'] < window[-1]['c'] / max(min((_x['l'] for _x in window[-3:])), 1e-09) and sum((_x['c'] * _x['v'] for _x in window[-20:])) / max(sum((_x['v'] for _x in window[-20:])), 1e-09) > sum((_x['h'] for _x in window[-120:])) / 120 and (sum((_x['c'] for _x in window[-90:])) / 90 < window[-1]['o'] and (sum((abs(window[-i]['c'] / max(window[-i - 1]['c'], 1e-09) - 1) for i in range(1, 45))) / 45 < th * 1.0758 or window[-1]['hh'] > c)):
return -1
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 状態(state)を導入
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
state['ref'] = state.get('ref') or window[-1]['c']
if window[-1]['c'] < state['ref'] * 0.9709:
state['ref'] = window[-1]['c']
return -1
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1] and window[-1]['h'] > sum((_x['c'] * _x['v'] for _x in window[-45:])) / max(sum((_x['v'] for _x in window[-45:])), 1e-09):
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 条件を厳しく/緩く
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1 and (window[-1].get('ts', 0.0) / max(sum((_x.get('ts', 0.0) for _x in window[-10:])) / 10, 1e-09) < u or window[-1].get('fx', 0.0) / max(sum((_x.get('fx', 0.0) for _x in window[-120:])) / 120, 1e-09) > (window[-1]['h'] - max(window[-1]['c'], window[-1]['o'])) / max(window[-1]['h'] - window[-1]['l'], 1e-09)):
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 条件を厳しく/緩く
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1 or (min(window[-1]['c'], window[-1]['o']) - window[-1]['l']) / max(window[-1]['h'] - window[-1]['l'], 1e-09) >= sum((_x.get('tb', 0.0) for _x in window[-14:])) / max(sum((_x.get('ts', 0.0) for _x in window[-14:])), 1e-09) * 0.9104:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 分岐を削除
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), window[-1]['c'])
if window[-1]['c'] < state.get('peak', 0.0) * 0.9834:
state['peak'] = 0.0
return -1
if c[-1] / c[-31] - 1 < -0.0012:
if c[-1] >= max((x['h'] for x in window[-60:])):
return -1
return 0
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
lead_ok = u <= 0 or True
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
lead_ok = False
if lead_ok and c[-1] < sma20 * (1 - 0.003333) and (window[-1]['l'] <= sum((x['l'] for x in window[-60:])) / 60):
return 1
return 0
# 狙い: 状態(state)を導入
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
state['ref'] = state.get('ref') or window[-1]['c']
if window[-1]['c'] < state['ref'] * 0.9668:
state['ref'] = window[-1]['c']
return -1
if c[-1] < state['peak'] * 0.9834:
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
th = 0.003333
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: 執行スタイル切替(taker成行 ⇔ maker指値)
def signal(window, state):
_exec = 'taker'
b = window[-1]
c = [x['c'] for x in window]
if c[-1] < max(c[-60:]) * 0.95:
return -1 if c[-1] >= max((x['h'] for x in window[-20:])) else 0
if c[-1] / c[-31] - 1 < -0.0012:
return 0
fr = b.get('fr', 0)
if fr > 0.0003:
return 0
th = 0.003333
if fr < 0:
th = 0.0025
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if not sum((_x['c'] * _x['v'] for _x in window[-20:])) / max(sum((_x['v'] for _x in window[-20:])), 1e-09) >= min((_x['l'] for _x in window[-10:])) * 0.9392:
return 1
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
if b['l'] >= c[-1]:
return 0
if c[-1] < sma20 * (1 - th) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0
# 狙い: else分岐を追加
def signal(window, state):
_exec = 'maker'
b = window[-1]
c = [x['c'] for x in window]
state['peak'] = max(state.get('peak', 0.0), c[-1])
if c[-1] < state['peak'] * 0.9834 and (not (window[-1].get('ta', 0.0) / max(sum((_x.get('ta', 0.0) for _x in window[-45:])) / 45, 1e-09) <= window[-1].get('u', 1.0) / max(window[-120].get('u', 1.0), 1e-09) * 0.9449 or max((_x['h'] for _x in window[-30:])) > sum((_x['c'] * _x['v'] for _x in window[-45:])) / max(sum((_x['v'] for _x in window[-45:])), 1e-09))):
state['peak'] = 0.0
return -1
if b['l'] >= c[-1]:
return 0
if c[-1] / c[-31] - 1 < -0.0012:
return -1 if c[-1] >= max((x['h'] for x in window[-60:])) else 0
if b.get('fr', 0) > 0.0003 or b.get('t1', 0) < -0.15 or b.get('fg', 50) > 80:
return 0
sma20 = sum(c[-20:]) / 20
u = b.get('u', 0)
if u > 0:
pu = window[-6].get('u', 0)
if pu > 0 and u / pu - 1 < c[-1] / c[-6] - 1:
return 0
elif window[-1]['v'] / max(sum((_x['v'] for _x in window[-120:])) / 120, 1e-09) >= u * 1.0927 and sum((_x['h'] - _x['l'] for _x in window[-30:])) / 30 <= window[-1]['c'] * 1.0914:
return 1
if c[-1] < sma20 * (1 - 0.0025) and b['l'] <= sum((x['l'] for x in window[-60:])) / 60:
return 1
return 0