
If you are an AlgoTrader or a systematic trader using Amibroker, you know the golden rule: Your backtest is only as good as the data you feed it.
We have all been there. You run a backtest on a portfolio of stocks, and the equity curve looks like a straight line to the moon. You think you’ve found the "Holy Grail," only to realize later that the strategy is worthless.
Why? Because your data had holes in it.
Today, we are looking at a critical concept in the Amibroker community often referred to as "Brokey" (or the process of detecting broken/missing data keys). We will explore what it is, why it destroys trading strategies, and how to use Amibroker’s native tools to fix it.
In your AFL code, add a Brokey risk filter: brokey for amibroker
// Before entering a trade
BrokeyRisk = ExRem(BrokeyRisk, False);
if( Buy AND NOT BrokeyRisk )
// Only enter if stock isn't on the "about to die" watchlist
SetPositionSize( 2, spsPercentOfEquity );
Additionally, use StaticVarGet to track an external “Brokey Score” for each ticker (based on debt-to-equity or price < $1 for 30 days).
Let’s get technical. Assuming you have sourced a delisted stock master file (a CSV with Ticker, DelistDate, FinalPrice), here is how to integrate the Brokey system. Mastering Amibroker: Why Your Backtests Might Be Wrong
Let’s say you are trading E-mini S&P 500 futures.
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: click your first swing point
Most traders ignore this. Brokey forces you to model it.