Bitcoin Channel Breakout is a MetaTrader 5 Expert Advisor designed for BTCUSD. It looks for a four-hour bar that closes above the highest high or below the lowest low of the previous 20 completed four-hour bars. A close above the channel signals a possible buy. A close below it signals a possible sell. Choose one of two strategies in the same EA.
B21 allows a buy when the latest complete daily close is above the 20-day simple average of daily closes. It allows a sell when the close is below that average. A four-hour breakout in the opposite direction can close a position regardless of the daily filter. B21 is the default.
B22 enters on the four-hour breakout and records the channel boundary that price crossed. A later four-hour close at or below that boundary closes a long position. A close at or above it closes a short. An opposite breakout can also trigger an exit.
All times use the broker's trade server clock. The EA evaluates new entries Monday through Thursday at 04:00, 08:00, 12:00 and 16:00, except from December 21 through January 3 inclusive. When the first valid quote after a four-hour close confirms an eligible entry, the EA waits at least 15 seconds. It attempts a market order on the first eligible quote after that wait. The opportunity expires 60 seconds after the four-hour close. For example, a signal observed at 08:00:07 can lead to an order from 08:00:22 up to, but excluding, 08:01:00. Quote arrival and broker execution determine when and at what price the order fills.
The stop-loss distance is based on three times four-hour ATR. The take-profit distance defaults to three times ATR and can be disabled by setting its multiplier to zero. The time exit falls due 96 hours after the signal bar closes, or sooner if Friday at 20:00 in the same week or December 20 at 20:00 in the same year comes first. The 15-second entry delay applies only to new positions.
By default, each order has a margin budget of 5% of account equity. The actual gain or loss depends on price movement, volume and execution. If account equity falls 1.5% from its daily reference or 10% from the recorded equity peak, the EA attempts to close its position and suspends new entries. These checks use equity for the whole account, including the effects of other trades.
Bitcoin Channel Breakout
User manual
1. Install and attach the EA
In MT5 for Windows, open Tools → Options → Community and sign in to the MQL5.community account used for the purchase. Install the EA from your purchased Market products. Connect to the broker account you want to use and open its BTCUSD chart from Market Watch. Where a broker uses a suffix or a different name, open the exact instrument you intend to trade. The EA trades the symbol of the chart you attach it to.
Drag Bitcoin Channel Breakout from Expert Advisors in the Navigator onto the chart. An H4 chart makes it easier to follow decision times. The EA uses one-hour history to calculate its own four-hour and daily bars on any chart timeframe.
Check the strategy and position size settings before confirming the Inputs tab. New entries are enabled by default. To start with entries disabled, set “Allow new entries” to false. To trade, set it to true and allow algorithmic trading in both the terminal and the EA's properties. After attachment, the EA waits for the next four-hour transition before evaluating a new entry.
2. Inputs
Strategy
The default is “B21 - daily trend filter”. It filters entries by the direction of the daily trend. “B22 - failed breakout exit” takes four-hour breakouts and adds an exit if the breakout fails. Run one instance per account and symbol. A change of strategy applies to future entries. The EA manages an already open position under the strategy that opened it.
Allow new entries
The default is true. Set it to false to suspend entries while the EA continues to manage its existing position. Keep algorithmic trading enabled in MT5 if the EA needs to send exit orders.
Margin budget (% of equity)
The default is 5.0. Enter a value greater than zero and no more than 100. For example, with account equity of 10,000 and a value of 5.0, the margin budget for a new order is 500 in account currency. The EA checks the broker's allowed volumes and required margin. It skips the trade if even the minimum volume exceeds the budget. The setting controls the margin used to open the trade. The price move to the stop, spread and execution affect the amount lost on a trade.
Take profit (ATR multiple, 0 = off)
The default is 3.0. A positive value sets the take-profit distance in multiples of four-hour ATR. Set it to zero to disable take-profit orders. The stop-loss distance is based on 3 ATR. The EA uses the entry quote and the broker's price increment to set protective order levels.
3. Signal and calendar
The EA combines four consecutive closed H1 bars in broker server time into a complete four-hour bar. It compares the latest four-hour close with the highest high and lowest low of the preceding 20 completed four-hour bars. A close strictly above the high can trigger a buy. A close strictly below the low can trigger a sell. ATR is the simple average of the last 14 four-hour true ranges.
B21 constructs a daily bar only when all six four-hour bars for that day are complete. A buy requires the latest completed daily close to exceed the simple average of the most recent 20 complete daily closes. A sell requires it to be below that average. Equality or fewer than 20 complete daily bars prevents entry. An opposite four-hour breakout can close a position regardless of the daily filter.
B22 uses the four-hour signal without the daily filter. It records the high of the previous 20 bars for a buy and the low of those bars for a sell. A subsequent four-hour close at or below the recorded high for a long, or at or above the recorded low for a short, triggers an exit attempt. The recorded boundary stays fixed for the life of the position. An opposite breakout can also trigger an exit.
Both strategies evaluate new entries Monday through Thursday at 04:00, 08:00, 12:00 and 16:00 in broker server time. New entries are suspended from December 21 through January 3 inclusive. Brokers with different server clocks, sessions or data gaps can produce different signals.
4. The 15-second entry delay
At the start of a new four-hour period, the EA evaluates the closed-bar signal once, on the first valid quote it receives. If the signal and order checks pass, that quote's timestamp starts the wait. On the first valid quote at least 15,000 milliseconds later, the EA rechecks eligibility, volume, margin and protective prices. If the checks pass, it attempts a market order. If they fail, it skips the rest of that entry window.
For example, a signal observed at 08:00:03.250 first becomes eligible at 08:00:18.250. If the first valid quote after the wait arrives at 08:00:20.100, that quote triggers the order check. The window expires at 08:01:00. If the first valid quote arrives as late as 08:00:48, the wait would extend past the deadline, so the EA skips that signal. A restart while an entry is waiting also discards that opportunity. The delay controls the earliest submission time. The fill timestamp also depends on broker execution.
5. Exits and equity safeguards
For a buy, the stop is set about 3 ATR below Bid. For a sell, it is set about 3 ATR above Ask. The profit target is set above Ask for a buy and below Bid for a sell by the selected ATR multiple. Gaps and broker execution can affect the price at which a protective order fills.
The time exit falls due at the earliest of 96 hours from the original four-hour signal close, Friday at 20:00 of the same week, or December 20 at 20:00 of the same year. Entry waiting time and the actual fill time do not extend that deadline. Signal and time exits have no added 15-second wait. The EA attempts to close when it can receive quotes and trade. Keep MT5 connected while a position is open.
The EA monitors equity for the whole account. A fall of 1.5% or more from the last observed equity before the server day changed suspends entries for that server day and triggers an attempt to close the EA's position. On the first day it uses its starting equity as the reference. A fall of 10% or more from the recorded equity peak also triggers an exit attempt and suspends new entries. The EA stores this peak-based halt across days and terminal restarts. Other trades, deposits and withdrawals can affect account equity.
If the EA finds its protective stop removed or moved farther from the original level, it attempts to close its position. On a netting account, adding a manual or another EA's entry to the same symbol can merge the trades into a single position. In that case, this EA withholds market close orders on the mixed position. Check the combined position and its protection in MT5.
6. Test and troubleshoot
In the Strategy Tester, select the EA and the BTCUSD symbol you plan to use. Choose a period with enough earlier H1 history and the “Every tick based on real ticks” model. B21 requires 20 complete daily bars. B22 needs at least 21 complete four-hour bars. To compare strategies, run each separately over the same period with the same account settings.
If you see no orders, check the broker's clock against the entry schedule, the relevant closing-price conditions and the availability of H1 history. Check the Experts log or tester Journal for initialization and order messages. A position or working order already on the chart symbol prevents a new entry. Also check trading permissions and free margin. MT5 can generate ticks for minutes with missing real ticks, so check tick history quality when auditing order times.
To verify the delay, locate ENTRY_ARMED and ENTRY_SUBMIT for the same signal in the log. Subtract reference_msc from quote_msc. The result is the elapsed quote time in milliseconds and should be at least 15,000. REQUEST reports the broker's response to the order, while the deal history records the fill. ENTRY_EXPIRED marks an armed signal that ran out of time.