// --- 4. Runtime assertions --- Assert( IsEmpty(Ref(Buy, +1)) OR Ref(Buy, +1) == 0, "Look-ahead detected" ); Assert( BuyPrice == Open, "Buy price not verified" );
Example header for verified AFL:
Using BuyPrice = Close when your system actually executes on the next day's open creates unverified results. Your code must match your broker's actual execution capabilities. Template for Verified AmiBroker AFL Code
AmiBroker's Walk-Forward settings optimize your code on an "In-Sample" data segment and validate it on an untouched "Out-of-Sample" segment. If the Out-of-Sample performance collapses completely, your code might be over-fitted or fundamentally unverified. Summary Checklist for Verified Code Checklist Item Prevents same-bar execution bias BuyPrice = Open Ensures execution happens at a tradable price CommissionAmount Factors in broker frictional costs BarIndex Check Ensures data loops do not look forward
The backtest assumptions perfectly match the realities of your broker’s execution, slippage, and commission structures. 2. Core Pillars of AFL Verification amibroker afl code verified
Before you deploy any AFL code to live trading or autotrading plugins (like Algosys, TrueData, or Interactive Brokers API), tick off this checklist: in the Formula Editor.
I can provide the exact, verified code snippet for your specific strategy. Share public link
Look-ahead bias is the most common reason backtest results look spectacular but fail in real life. It happens when code uses future information to generate a signal today.
function Assert( condition, message )
: Set breakpoints to pause execution and hover over variables to see their current values.
Ref functions like Ref(Close, 1) are correct. Ensure no accidental Ref(..., -1) (future data) in backtest signals.
What (e.g., Breakout, Mean Reversion) are you using?
Verified AFL code means the script has been rigorously tested and audited to match real-world market execution. Core Pillars of Verification // --- 4
// --- 5. EXITS (Volatility stop - Verified to prevent re-entry) --- Sell = Buy = 0; // Reset overrides Cover = Short = 0;
❌
Verify AFL syntax passes without errors. Use the built‑in AFL Editor’s syntax check.
To confirm an AFL script is "verified," traders and developers typically use these three layers of testing: Ref functions like Ref(Close