What are you seeing in your code?
| Pitfall | Why It’s Problematic | How to Avoid | | :--- | :--- | :--- | | | Positive arguments reference future bars, introducing look‑ahead bias and invalid backtest results. | Always use a negative argument to refer to past data. | | Array arguments in if statements | if requires a single scalar value. Passing an array is syntactically allowed but logically ambiguous and will not work as expected. | Use LastValue(array) or reference a specific index ( array[index] ) to get a scalar. | | Hard‑coded bar counts in loops | The code will crash with Error 10 if a symbol has fewer bars than the hard‑coded limit. | Loop from 0 to BarCount-1 , or check if(BarCount > 300) first. | | Misusing IIf() for strings | IIf() returns an array, not a string. Using it for text generation will produce unexpected results. | Use WriteIf() for conditional string outputs. | | Forgetting that parameters are not automatically reset | When pasting a new strategy over an existing one, old parameter values can persist and corrupt your test. | Click the "Reset all" button in the Parameters dialog before running a new backtest. | | Using Notepad or external editors | Saving code with Notepad may inadvertently change the file extension to .txt , and external editors may not save changes automatically before a backtest. | Always use the built‑in AFL Editor; the Analysis window automatically saves the current file when you run a scan or backtest. | | Assuming prices are never zero | Writing C == 0 as a signal will never trigger for stocks, rendering your strategy inactive. | Use explicit False or 0 if you want a condition that never fires. |
Any vendor who refuses to show a verified Monte Carlo or Walk-Forward analysis in Amibroker’s native report format is hiding something. Demand to see the Equity Curve (log scale) and Underwater Plot .
AmiBroker Formula Language (AFL) is a powerful tool, but a "verified" tag on code is the difference between a winning strategy and a blown account. Why Verification Matters amibroker afl code verified
Before relying on a strategy for live trading, it is wise to profile your code for efficiency. AmiBroker includes an (available under Tools -> Code Check & Profile in the AFL Editor) that provides a detailed per‑function timing report. This helps identify bottlenecks—such as unnecessary loops, repeated calculations, or heavy array operations—that could degrade performance when processing thousands of symbols or in a real‑time environment.
Open your code in the AmiBroker Formula Editor. Click the button. Fix all errors and structural warnings immediately. Step 2: Check for Future Leaks
must include a settings header or instructions: What are you seeing in your code
The interface is often described as looking like it’s from the 1990s.
: Variables are defined before use, and function arguments match the expected types. Compiler Approval
Verified AFL code ensures that the backtesting results of your trading strategies are accurate. This means that the performance metrics you obtain (like profit/loss, drawdown, etc.) are reliable. | | Array arguments in if statements |
Look-ahead bias occurs when your code accidentally uses future information to generate a past signal. This creates perfect backtest results that are impossible to replicate in real life.
You don’t need to buy verified code—learn to verify your own. Insert this verification snippet at the end of any AFL script:
AFL is a high-level array-based language similar to C and JScript, but optimized for financial data . Code is considered verified when: Syntax is Correct