Strategy Tutorials
Whether you have never written a line of trading code or you are an experienced quant looking to implement institutional-style strategies, these tutorials walk you through building real algorithms that run in the TestMax Algo Playground.
Every tutorial includes complete, runnable Python code that you can paste directly into the Playground editor and backtest immediately.
How These Tutorials Work
Each tutorial builds a strategy from scratch using the TestMax API. You will:
- Learn the concept — the trading idea behind the strategy
- See the code — full Python implementation with every line explained
- Run it — paste into the Algo Playground, pick an instrument and date range, and hit Run
- Analyze results — use TestMax’s built-in analytics to evaluate performance
Prerequisites
- Basic Python knowledge (variables, loops, if/else, functions)
- A TestMax account with access to the Algo Playground
- Curiosity about how markets work
No prior trading experience is required — the beginner track starts from zero.
Beginner Track
Start here if you have never built a trading algorithm. These tutorials cover the fundamentals: what market data looks like, how to place orders, and how to build simple rule-based strategies.
After completing the beginner track, you will be able to:
- Read and interpret OHLCV bar data
- Place market orders with the TestMax API
- Implement moving average calculations from scratch
- Build a complete crossover strategy with entry and exit logic
Intermediate Track
Build on the fundamentals with more sophisticated indicators, multi-signal systems, and — critically — risk management. The difference between a toy strategy and a real one is almost always risk controls.
After completing the intermediate track, you will be able to:
- Calculate RSI, ATR, and Donchian Channels from raw bar data
- Build breakout systems with false-breakout filtering
- Implement daily loss limits, max trade caps, and consecutive loss protection
- Combine trend, momentum, and volatility indicators into a single strategy
Advanced Track
Institutional-grade concepts: ICT Smart Money theory, bracket orders with stop loss and take profit, parameter optimization, and porting your strategy from TestMax to live trading on TopStep.
After completing the advanced track, you will be able to:
- Detect market structure shifts, fair value gaps, and liquidity sweeps in code
- Use bracket orders to automate risk management per trade
- Optimize strategy parameters using grid search and walk-forward analysis
- Migrate a TestMax strategy to live trading on TopStep with minimal changes
Quick Reference: The TestMax API
Every strategy uses these core functions. They are available automatically in the Algo Playground — no imports needed.
# Step through historical data one bar at a timebar = get_next_bar()# Returns: {"t": "2025-01-15T14:30:00", "o": 21500.25, "h": 21505.50, "l": 21498.00, "c": 21503.75, "v": 1234}
# Place an orderplace_order(account_id, contract_id, side, size, order_type=2, limit_price=None, stop_price=None)# side: 0 = Buy, 1 = Sell# order_type: 1 = Limit, 2 = Market, 4 = Stop
# Check open positionspositions = get_positions(account_id)
# Close everythingclose_all_positions(account_id, contract_id)
# Get account balance and infoaccount = get_account(account_id)
# Read playback speed from UI sliderspeed = read_speed()Suggested Learning Path
If you are brand new, go in order: beginner track first, then intermediate, then advanced. Each tutorial builds on concepts from the previous ones.
If you already know Python and basic trading concepts, jump to whichever tutorial interests you — they are designed to be self-contained. Just read Your First Algorithm first so you understand the Playground’s API and execution model.