Brokey For Amibroker
Add this to the code if you want only high-volume breakdowns:
VolumeSurge = V > MA(V, 20) * 1.5;
BrokeySignal = Confirmed AND NOT Ref(Confirmed, -1) AND VolumeSurge;
✅ Now you have a ready-to-use "Brokey" breakdown detector for AmiBroker.
Copy, paste, and hunt for breakdowns across your watchlist.
Brokey handling of mergers is tricky. If Stock A merges into Stock B, your AmiBroker database might just delete Stock A. A proper Brokey approach:
Most traders ignore this. Brokey forces you to model it.
This is the heart of Brokey. Go to Analysis > Settings > Backtester > Custom Backtester. Write or paste a script that loops through all trades and flags delisted positions. brokey for amibroker
Sample CBI logic:
// JavaScript for AmiBroker Custom Backtester
for each trade in Backtest.Trades
if (trade.Symbol.IsDelisted && trade.ExitDateTime >= trade.Symbol.DelistDate)
trade.ExitPrice = trade.Symbol.DelistPrice; // e.g., 0.01
trade.ExitReason = "Brokey - Delisted";
trade.RealizedPnL = -trade.EntryValue; // Total loss
This overrides AmiBroker’s default assumption that you can always sell at the close on the final bar.
Commands/tips:
Set these by editing variables at the top of the AFL script or through provided UI inputs if the Brokey version supports them. Add this to the code if you want
If you have spent any time developing trading systems in AmiBroker, you know it is one of the most powerful, flexible, and fastest backtesting platforms available. You’ve meticulously coded your entry signals, optimized your stops, and watched your equity curve climb steadily. But there is a silent, pernicious enemy lurking in your data that can turn your million-dollar strategy into a live-market disaster.
That enemy is the survivorship bias, the quote bias, and the illiquidity trap. And the weapon to slay it? Brokey for AmiBroker.
For the uninitiated, “Brokey” (officially known as Brokey’s Data Cleaner & Backtest Enhancer) is not a household name like Norgate or CSI Data. It is the underground workhorse—a specialized utility and data management philosophy designed to fix what AmiBroker’s native database often overlooks: the reality of broken, delisted, and illiquid stocks.
This article is your complete roadmap. We will explore what Brokey is, why you need it, how to install and configure it, and the advanced techniques that separate professional-grade backtests from amateur wishful thinking. ✅ Now you have a ready-to-use "Brokey" breakdown
The manual way to check for "Brokey" data is to open the Quote Editor (Symbols -> Edit).
Scroll through your data. Do you see dates missing? Do you see 0 or Null values in the Volume column? This is tedious for one stock and impossible for a database of 2,000 symbols.
Interpretation:
Optimization (Parameters):