Skip to main content
Version: 1.0.0

Moving Average Cross

Blocks

Python

# handle new bars during simulation
def handle_new_bar(data, emit, blocks):
if data.SMA(25) > data.SMA(200):
emit.Buy(type="max", reason="25 bar SMA < 200 bar SMA", order_type="market")

if data.SMA(25) < data.SMA(200):
emit.Sell(type="max", reason="25 bar SMA > 200 bar SMA", order_type="market")