Blog / Strategy
Strategy

Candle Range Theory: CRT Strategy Rules Coded in MT5

Disclaimer: This article is for educational and informational purposes only. It does not constitute financial or investment advice. Trading forex and CFDs carries significant risk of loss. Past performance of any strategy – including backtests – does not guarantee future results. Never trade with money you cannot afford to lose.

What Is This Strategy?

The candle range theory strategy is a price-action reversal method that uses a three-candle pattern and no indicators. One candle sets a range, the next pushes past one side of it and fails, and the trade aims back at the opposite side. The code uses only the high, low and close of the two most recently completed candles.

Candle Range Theory (CRT) is popular in ICT-style (Inner Circle Trader) and "smart money" circles. Its core idea is liquidity, meaning the resting orders clustered at obvious price levels. Many traders place stop-losses just beyond a prominent candle's high or low. When price moves past that level, triggers those orders and then closes back inside the range, CRT reads the move as a stop raid rather than a real breakout. It expects price to swing toward the other end of the range next.

This Expert Advisor (EA, an automated trading program for MetaTrader) turns that discretionary idea into fixed rules. That makes it a useful way to study candle range theory trading with every decision defined in advance. You will learn how often the pattern appears, how wide its stops tend to be and how much each threshold changes the outcome. Treat it as something to study and backtest, not as a finished trading system.

How It Works

The EA checks for a setup once per completed bar. When a new candle opens, it gives each of the last two closed candles a role.

How the Candle Range Theory Strategy Reads Three Candles

Entry Conditions

For a short (sell) signal:

The rules for a long (buy) signal are the mirror image, with the sweep happening below candle 1's low instead.

A very shallow sweep may just be noise. A very deep one looks more like a real breakout that pulled back. An outside bar breaks both the high and the low, so it gives no clear direction, and the EA ignores it.

Stop-Loss and Take-Profit Logic

candle range theory strategy
Illustrative example of the strategy’s entry and exit logic — not real trading results.

Strategy Parameters

Parameter Default Min Max Description
MinSweepFraction 0.03 0.00 0.30 The smallest distance candle 2 must trade beyond the range edge, as a fraction of the range height. It filters out tiny pokes.
MaxSweepFraction 0.60 0.10 1.50 The largest allowed sweep depth, as a fraction of the range height. Deeper moves count as real breakouts and are skipped.
StopBufferFraction 0.05 0.00 0.30 Extra room added beyond the sweep candle's extreme when the stop is placed, as a fraction of the range height.
MinRewardRisk 1.5 1.0 3.0 The smallest reward-to-risk ratio needed to take a trade.
MaxHoldBars 3 0 10 The number of bars after which an open trade is closed at market. 0 turns this off.
Lots 0.10 0.01 1.0 The fixed order size, rounded to the broker's volume step and limits.

The MQL5 version also has a Magic input (default 240617). It identifies the EA's trades and is not meant to be optimized.

candle range theory strategy — MQL5 source code

Recommended Chart Settings

Results will vary across market conditions. Trending, ranging and news-driven periods can behave very differently, so test across several years.

How to Install on MetaTrader 5

Before you trade the candle range theory MT5 version live, run it in the Strategy Tester with "Every tick based on real ticks" modeling, then forward-test it on a demo account. For every trade, the Experts log records the swept level, entry, stop, target and R.

What to Consider Before Using This EA

Strengths

Limitations

The approach may underperform during sustained breakouts, in very quiet markets and around major economic announcements.

Risk Management Tips

Risk Warning

Trading foreign exchange, CFDs, and other leveraged financial instruments involves substantial risk of loss and is not suitable for all investors. The strategies and tools discussed on this page are provided for educational purposes only and do not constitute financial advice, investment recommendations, or solicitation to trade. Always consult a qualified financial adviser before making trading decisions. Past backtest performance is not indicative of future results.

Downloads

← Back to Blog