Hi, I am Mohak, Senior Quant at QuantInsti. In the following video, I take a classic breakout idea, Donchian Channels, and show how to turn it into code you can trust, test it on real data, and compare a few clean strategy variants. My goal is to make the jump from “I get the concept” to “I can run it, tweak it, and judge it” as short as possible.
What we cover in the Video
The indicator in plain English. Donchian Channels track the highest high and lowest low over a lookback window. That gives you an upper band, a lower band, and a middle line. I also show a small but important step: shift the bands by one bar so your signals do not peek into the future.
Three strategy shapes.
- Long-short, one window (N). Go long when the price closes above the upper band, go short when it closes below the lower band. Stay in the trade until the opposite signal arrives.
- Long-only, one window (N). Enter on an upper-band breakout. Exit to cash if the price closes below the lower band.
- Separate entry and exit windows (N_entry, N_exit). A Turtle-style variant. Use a slower window to enter and a faster window to exit. This simple asymmetry changes behaviour meaningfully.
Bias control and realism.
We use adjusted close prices for returns, shift signals to avoid look-ahead bias, and apply transaction costs on position changes so the equity curve is not a fantasy.
Benchmarking properly.
I put each variant next to a buy-and-hold baseline over a multi-year period. You will see where breakouts shine, where they lag, and why exits matter as much as entries.
What you will learn
- How to compute the bands and wire them into robust entry and exit rules
- Why a one-line shift can save you from hidden look-ahead bias
- How different window choices and shorting permissions change the character of the strategy
- How to read equity curves and basic stats like CAGR, Sharpe, and max drawdown without overfitting your choices
Why this matters
Breakout systems are transparent, testable, and easy to extend. Once the plumbing is correct, you can try portfolios, volatility sizing, regime filters, and walk-forward checks. This is the scaffolding for that kind of work.
Download the Code
If you want to replicate everything from the video, download the codes below.
Next Steps
- Pressure-test the idea. Change windows, tickers, and date ranges. Check if results hold outside your calibration period. Try a simple volatility position sizing rule and see what it does to drawdowns.
- Portfolio view. Run a small basket of liquid instruments and equal-weight the signals. Breakouts often behave better in a diversified set.
- Walk-forward logic. Split the data into in-sample and out-of-sample, or do a rolling re-fit of windows. You want robustness, not a one-off lucky decade.
Learn and build with QuantInsti
Quantra: hands-on courses you can finish this week
If you want structured, bite-sized learning that complements this video, start with Quantra. Begin with Python and backtesting fundamentals, then move to learning tracks.
Quantra is a Python-based, interactive e-learning platform by QuantInsti for quantitative and algorithmic trading. It provides self-paced courses with a focus on practical, hands-on learning to teach users how to develop, backtest, and implement trading strategies, including those using machine learning.
Explore courses on Quantra
EPAT: a complete path into quant roles and workflows
If you are ready for depth and career outcomes, EPAT gives you a broad, applied curriculum with mentorship and an active alumni network. It connects the dots from research to execution across markets and asset classes.
EPAT (Executive Programme in Algorithmic Trading) by QuantInsti is a comprehensive, online, 6-month certification program designed to equip professionals and aspirants with the skills needed for algorithmic and quantitative trading. It covers a wide curriculum from foundational finance and statistics to advanced topics like AI/ML in trading and is taught by industry experts. The program includes live lectures, hands-on projects, and focuses on practical skills in Python, backtesting, and strategy implementation.
Discover EPAT
Blueshift: take your research toward live
When your research looks solid, move to Blueshift for higher-quality simulations. Blueshift is an all-in-one automated trading platform that brings institutional-class infrastructure for investment research, backtesting, and algorithmic trading to everyone, anywhere and anytime. It is fast, flexible, and reliable. It is also asset-class and trading-style agnostic. Blueshift helps you turn your ideas into investment-worthy opportunities.
Build on Blueshift
Disclaimer: This blog post is for informational and educational purposes only. It does not constitute financial advice or a recommendation to trade any specific assets or employ any specific strategy. All trading and investment activities involve significant risk. Always conduct your own thorough research, evaluate your personal risk tolerance, and consider seeking advice from a qualified financial professional before making any investment decisions.

