SlideShare a Scribd company logo
ABXC
AmiBroker Xtreme Course
Custom Backtester Interface (CBI)
1
ABXC
By ThaiQuants.com
AmiBroker treme Course
2
ABXC
3
ABXC
4
ABXC
5
DRAWBACKS
• Improper Start & Capital
• Unjustified Knowledge
• Unqualified Skill
• Lack of Experience
• Trial and Error Approach
• Underestimated Risk
• Biases
• No quantitative Backtest
• No self assessment
• …
ABXC
AmiBroker
6
ABXC
7
User Friendly Charting with Indicators
Portfolio Backtesting Advanced Scanning
ABXC
AmiBroker’s Backtesting
8
ABXC
9
ABXC
10
In order to go FAST, you must go Slow.
ABXC
AmiBroker Xtreme Course
Standard Backtesting
11
ABXC
12
Portfolio Metrics
Trade List
2 31
ABXC
13
Portfolio Metrics
Trade List
INPUT OUTPUT
AFL Code
1. Reports
2. Signals: Score & Size & Equity
3. Trades: Entry & Exit & Stop
ABXC
14
Portfolio Metrics
Trade List
3
4
2 51
BACKTESTING
• Run Backtest
• Mark/CleanSignals
• Buy & Sell
• CalculateScore & Size
• Process Trades
• Update Stats
• Handle Stops
• Scale Trades
• GenerateReport
1. Reports
2. Signals: Score & Size & Equity
3. Trades: Entry & Exit & Stop
ABXC
AmiBroker Xtreme Course
Custom Backtester Interface (CBI)
15
ABXC
16
Portfolio Metrics
Trade List
3
4
2 51
BACKTESTING
• Run Backtest
• Mark/CleanSignals
• Buy & Sell
• CalculateScore & Size
• Process Trades
• Update Stats
• Handle Stops
• Scale Trades
• GenerateReport
ABXC
17
Portfolio Metrics
Trade List
3
4
BACKTESTING
• Run Backtest
• Mark/CleanSignals
• Buy & Sell
• CalculateScore & Size
• Process Trades
• Update Stats
• Handle Stops
• Scale Trades
• GenerateReport
51 2
ABXC
What is Custom Backtester Interface?
18
CUSTOM BACKTESTING
• Run Backtest
• Mark/CleanSignals
• Buy & Sell
• CalculateScore & Size
• Process Trades
• Update Stats
• Handle Stops
• Scale Trades
• Generate Report
Difficult & Dangerous!
Example:
• Current Equity = 1,000,000
• Equity = Cash + OpenPositions
Equity = 1,200,00;
ABXC
What is Custom Backtester Interface?
19
CUSTOM BACKTESTING
• Run Backtest
• Mark/CleanSignals
• Buy & Sell
• CalculateScore & Size
• Process Trades
• Update Stats
• Handle Stops
• Scale Trades
• Generate Report
ABXC
What is Custom Backtester Interface?
20
CUSTOM BACKTESTING
• Run Backtest
• Mark/CleanSignals
• Buy & Sell
• CalculateScore & Size
• Process Trades
• Update Stats
• Handle Stops
• Scale Trades
• Generate Report
To properly manage and control custom backtest
Backtester Object, BO
ABXC
21
5
Portfolio Metrics
Trade List
++ Metrics
++ Metrics
1 2
3
4
CUSTOMBACKTESTING
• Run Backtest
• Mark/CleanSignals
• Buy & Sell
• CalculateScore & Size
• Process Trades
• Update Stats
• Handle Stops
• Scale Trades
• Modify/AddReports
//Codefor BO
bo.Backtest();
bo.AddCustomMetric();
bo.ProcessTradeSignals();
bo.ScaleTrade();
ABXC
What is Custom Backtester Interface?
22
CUSTOM BACKTESTING
• Run Backtest
• Mark/CleanSignals
• Buy & Sell
• CalculateScore & Size
• Process Trades
• Update Stats
• Handle Stops
• Scale Trades
• Generate Report
To properly manage and control custom backtest
Backtester Object, BO
ABXC
What is Custom Backtester Interface?
23
CUSTOM BACKTESTING
• Run Backtest
• Mark/CleanSignals
• Buy & Sell
• CalculateScore & Size
• Process Trades
• Update Stats
• Handle Stops
• Scale Trades
• Generate Report
Difficult & Dangerous!
ABXC
AmiBroker Xtreme Course
3 Levels of CBI
24
Reports
ABXC
25
To go Higher, you must go Deeper.
ABXC
26
Portfolio Metrics
Trade List
INPUT OUTPUT
AFL Code
1. Reports
2. Signals: Score & Size & Equity
3. Trades: Entry & Exit & Stop
ABXC
27
Three Levels of Custom Backtester Interface
High-Level CBI: Reports
Mid-Level CBI: Signals
Low-Level CBI: Trades
Reports
ABXC
28
Application of 3-Level CBI
High-Level CBI: Reports (BT Results)
• Portfolio Metrics
• Trade Metrics
Mid-Level CBI: Signals
• Reject signals
Low-Level CBI: Trades
• Manage Trades and Stops
Reports
ABXC
Example of High-Level CBI: Reports
29
High Level CBI
+Mid Level CBI
ABXC
Example of Mid-Level CBI: Signals
30
Reject Signals
ABXC
Example of Low-Level CBI: Trades
31
Scale out trades
ABXC
32
Application of 3-Level CBI
High-Level CBI: Reports (BT Results)
• Portfolio Metrics: Expectancy, SQN, Drawdown Period, …
• Trade Metrics: R-Multiples
Mid-Level CBI: Signals
• Reject signals, or Change position size
• Control risk from signals and open positions
Low-Level CBI: Trades
• Manage Trades: Enter, Exit, and Stop
• Scale trades: Scale In & Out
Reports
ABXC
33
Application of 3-Level CBI
High-Level CBI: Reports
Mid-Level CBI: Signals
Low-Level CBI: Trades
Reports
ABXC
Cautions about Custom Backtester Interface
•Requiring more coding skill
•Harder to debug
•Error prone and might be misunderstood
•Time-consuming Backtesting
•Complex Calculation: Risks & Scale In/Out
•The more complicated the Code, the harder the Trades (Real Execution)
•Difficult to Monitor: positions, stops, and portfolio
34
ABXC
AmiBroker Xtreme Course
AmiBroker’s 2-Phrase Backtesting
35
ABXC
AmiBroker’s 2-Phrase Backtesting
36
1.1 Collect raw signals
1.2 Clean signals
1.3 Update Equity & Stats
1.4 Calculate Position Score & Size
2.1 Analyze Score & Size “Bar by Bar”
2.2 Trade Signals (Entries & Exits)
2.3 Handle Stops
2.4 Update Stats
MaxOpenPositions = 2
PHRASE1PHRASE2
ABXC
AmiBroker’s 2-Phrase Backtesting
37
PHRASE1PHRASE2
ABXC
High-Level CBI: Reports
38
Reports//Code calculating new metrics
bo.AddCustomMetric();bo.Backtest()
PHRASE1PHRASE2
ABXC
Mid-Level CBI: Signals
39 bo.PreProcess()bo.PostProcess()
//Code Modifying Signals
bo.ProcessTradeSignals();
Phase 1
1.1 Collect raw signals
1.2 Clean signals
1.3 Update Equity & Stats
1.4 Calculate Position Score & Size
Phase 2
2.1 Analyze Score & Size “Bar by Bar”
2.2 Trade Signals (Entries& Exits)
2.3 Handle Stops
2.4 Update Stats
PHRASE1PHRASE2
ABXC
Comparison between HL & ML CBI
40
Reports
//Code calculating new metrics
bo.AddCustomMetric();bo.Backtest()
bo.PreProcess()bo.PostProcess()
//Code Modifying Signals
bo.ProcessTradeSignals();
PHRASE1PHRASE2
ABXC
Low-Level CBI: Trades
41 bo.PreProcess()bo.PostProcess()
//Code Executing Trades!
bo.EnterTrade();
bo.ExitTrade();
bo.ScaleTrade();
bo.HandleStops();
bo.UpdateStats();
PHRASE1PHRASE2
ABXC
AmiBroker Xtreme Course
Simplified CBI Code Templates
42
ABXC
bo.Backtest();
bo.GetPerformanceStats();
bo.AddCustomMetric();
43
bo.PreProcess();
.PosSize
.PosScore
bo.ProcessTradeSignals();
bo.PostProcess();
bo.PreProcess();
bo.EnterTrade();
bo.ExitTrade();
bo.HandleStops();
bo.ScaleTrade();
bo.UpdateStats();
bo.PostProcess();
bo = GetBacktesterObject();
Reports
HL CBI
Reports
ML CBI
Signals
LL CBI
Trades
ABXC
bo.PreProcess();
.PosSize
.PosScore
bo.ProcessTradeSignals();
bo.PostProcess();
bo.Backtest();
bo.GetPerformanceStats();
bo.AddCustomMetric();
44
bo.PreProcess();
bo.EnterTrade();
bo.ExitTrade();
bo.HandleStops();
bo.ScaleTrade();
bo.UpdateStats();
bo.PostProcess();
FOR-LOOPS (minimum)
Reports
HL CBI
Reports
ML CBI
Signals
LL CBI
Trades
For-loop Bar
For-loop Signals
For-loop Bar
For-loop Signals
For-loop OpenPositions
ABXC
45
Yeah! That’s pretty much about the Concepts.
Now. Let’s CODE!
ABXC
AmiBroker Xtreme Course
High-Level CBI: Reports
46
Reports
ABXC
AmiBroker Xtreme Course
Mid-Level CBI: Signals
47
ABXC
AmiBroker Xtreme Course
Low-Level CBI: Trades
48

More Related Content

PDF
Price Action Trading - An Introduction
PPTX
Monte Carlo Simulation for Trading System in AmiBroker
PDF
How to build a trading system
PDF
"Trading Strategies That Are Designed Not Fitted" by Robert Carver, Independe...
PPTX
"From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D...
PDF
What we learned from running a quant crypto hedge fund
PDF
Magic Forex breakout
PPTX
DIY Quant Strategies on Quantopian
Price Action Trading - An Introduction
Monte Carlo Simulation for Trading System in AmiBroker
How to build a trading system
"Trading Strategies That Are Designed Not Fitted" by Robert Carver, Independe...
"From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D...
What we learned from running a quant crypto hedge fund
Magic Forex breakout
DIY Quant Strategies on Quantopian

What's hot (20)

PPTX
Overview of price action trading
PDF
"A Framework-Based Approach to Building Quantitative Trading Systems" by Dr. ...
PPTX
Probabilities in trading
PDF
Introduction to elliott_wave_fibonacci_spread_trading
PDF
ΠΡΟΠΟΝΗΣΗ ΤΑΧΥΔΥΝΑΜΗΣ ΣΕ ΠΑΙΔΙΑ
PPTX
"Quant Trading for a Living – Lessons from a Life in the Trenches" by Andreas...
PPTX
"How to Run a Quantitative Trading Business in China with Python" by Xiaoyou ...
PPTX
"A Framework for Developing Trading Models Based on Machine Learning" by Kris...
PPTX
Amit Gulecha Presentation at Traders Carnival 2018
PPTX
How to use VWAP as an important technical indicator
PDF
Trade what you see not what you think
PPTX
Sebastian seliga trading psychology.pptx
PDF
Trading the cloud the tenken sen
PPTX
Elliott Wave Setups for Forex Trading
PDF
"Fundamental Forecasts: Methods and Timing" by Vinesh Jha, CEO of ExtractAlpha
PDF
Simple trading strategy for beginners
PDF
Master binary options trading ebook
PPT
Bhavishya- Elliot Wave Theory
PDF
Zero To Hero : Complete Binary Options Trading Guide
PPTX
SSYS Reversal Fade Trade
Overview of price action trading
"A Framework-Based Approach to Building Quantitative Trading Systems" by Dr. ...
Probabilities in trading
Introduction to elliott_wave_fibonacci_spread_trading
ΠΡΟΠΟΝΗΣΗ ΤΑΧΥΔΥΝΑΜΗΣ ΣΕ ΠΑΙΔΙΑ
"Quant Trading for a Living – Lessons from a Life in the Trenches" by Andreas...
"How to Run a Quantitative Trading Business in China with Python" by Xiaoyou ...
"A Framework for Developing Trading Models Based on Machine Learning" by Kris...
Amit Gulecha Presentation at Traders Carnival 2018
How to use VWAP as an important technical indicator
Trade what you see not what you think
Sebastian seliga trading psychology.pptx
Trading the cloud the tenken sen
Elliott Wave Setups for Forex Trading
"Fundamental Forecasts: Methods and Timing" by Vinesh Jha, CEO of ExtractAlpha
Simple trading strategy for beginners
Master binary options trading ebook
Bhavishya- Elliot Wave Theory
Zero To Hero : Complete Binary Options Trading Guide
SSYS Reversal Fade Trade
Ad

Recently uploaded (20)

PDF
01-Introduction-to-Information-Management.pdf
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
Basic Mud Logging Guide for educational purpose
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Institutional Correction lecture only . . .
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
VCE English Exam - Section C Student Revision Booklet
01-Introduction-to-Information-Management.pdf
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Basic Mud Logging Guide for educational purpose
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Final Presentation General Medicine 03-08-2024.pptx
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Anesthesia in Laparoscopic Surgery in India
Institutional Correction lecture only . . .
Microbial diseases, their pathogenesis and prophylaxis
Renaissance Architecture: A Journey from Faith to Humanism
VCE English Exam - Section C Student Revision Booklet
Ad

AmiBroker Custom Backtester Interface