# Premiss research template v1: sma_crossover
PARAMS = {}
WINDOW = 51

def on_bar(ctx):
    if len(ctx.closes) < 50:
        ctx.note("Waiting for 51 closed candles of history")
        return
    fast = ctx.closes[-20:].mean()
    slow = ctx.closes[-50:].mean()
    ctx.target(1.0 if fast > slow else 0.0)
    ctx.note(f"Fast SMA {fast:.4f}, slow SMA {slow:.4f}: target long" if fast > slow else f"Fast SMA {fast:.4f}, slow SMA {slow:.4f}: target cash")
