understand foreign equity in amibroker

11
Understand Foreign(“~~~Equity”, “C”) AMIBROKER QUANT COURSE By ThaiQuants.com 05/10/15

Upload: thaiquants

Post on 09-Jan-2017

512 views

Category:

Education


3 download

TRANSCRIPT

Page 1: Understand Foreign Equity in AmiBroker

Understand Foreign(“~~~Equity”, “C”)

AMIBROKER QUANT COURSE

By ThaiQuants.com 05/10/15

Page 2: Understand Foreign Equity in AmiBroker

Foreign(“~~~Equity”, “C”);

This slide

•Focus on Foreign(“~~~Equity”, “C”);

•Depict problems in using Foreign(“~~~Equity”, “C”);

Previous slide

•Give guideline and recommendation for Code Position the Right Way

•Focus on PositionSize and PositionScore

•Show Equity pays an important role in Position Sizing

61 IMPORTANT: The best way to use Current Equity is coding with Custom Backtester Interface (CBI).

Page 3: Understand Foreign Equity in AmiBroker

Foreign(“~~~Equity”, “C”);

•Save data in symbol “~~~Equity”

•Automatically created by AmiBroker

•For Charting or preliminary coding/designing strategy

• Initial value is Zero (an array filled with zero)

•Updated at the end of each Backtest

•Keeps changing (one backtest to another until reaching …)

•Not work with Optimization (unless already have data)

•Accuracy … depends on many

62 By ThaiQuants.com 05/10/15

Page 4: Understand Foreign Equity in AmiBroker

Code for Testing

//POSITION

e = Foreign(“~~~Equity”, “C”);

PositionSize = 0.05*e;

PositionScore = C*V;

63 IMPORTANT: The best way to use Current Equity is coding with Custom Backtester Interface (CBI).

Page 5: Understand Foreign Equity in AmiBroker

Signal Tables – Same code, different Backtest

64

Never change

Keep changing,

depending on

1. Current Equity

2. PositionSize

3. PositionScore

4. ApplyStop

From Code in Signal Section

From Code in Position Section

Note: More in MM and CBI sections

Page 6: Understand Foreign Equity in AmiBroker

Backtest from 1st to 3rd Run

Aft

er 2

nd

Ru

nA

fte

r 3

rdR

un

Be

fore

1st

Ru

n

Foreign(“~~~Equity”, “C”)

Aft

er

1st

Ru

n

SetOption(“InitialEquity”, 1000000)

By ThaiQuants.com 05/10/15

Page 7: Understand Foreign Equity in AmiBroker

4th

Ru

n5

thR

un

6th

Ru

n7

thR

un

Backtest from 4th to 7th Run

By ThaiQuants.com 05/10/15

Page 8: Understand Foreign Equity in AmiBroker

8th

Ru

n9

thR

un

10

thR

un

11

thR

un

Backtest from 8th to 11th Run

By ThaiQuants.com 05/10/15

Page 9: Understand Foreign Equity in AmiBroker

Foreign(“~~~Equity”, “C”);•Before 1st Run: Zero!!!

•During 1st Run: Zero!!!

•End of 1st Run: InitialEquity

•During 2nd Run: using this InitialEquity in PositionSize

•End of 2nd : saving the new equity

•During 3rd : using new equity from 2nd Backtest

•End of 3rd : saving new equity

•During 4th : using equity from 3rd

•… until 9th Run68

Page 10: Understand Foreign Equity in AmiBroker

By ThaiQuants.com 05/10/15

e = Foreign(“~~~Equity”, “C”); PositionSize = 0.05*e;

e = Equity(); PositionSize = 0.05*e;

Position = -5;

SetPositionSize(5, spsPercentOfEquity);

Backtesting Results

Page 11: Understand Foreign Equity in AmiBroker

IMPORTANT: The best way to use Current Equity is coding with Custom Backtester.

Comparison of Equity Code

for Backtesting

70

Equity Code Easy to Code Flexibility Accuracy Recommend

e = Equity() Yes Yes Worst Avoid

e = Foreign(“~~~Equity”, “C”) Yes Yes Not really Use with cautious

PositionSize = -x; Yes Yes Best Keep it simple

SetPositionSize(x, spsPercentOfEquity); Yes Not really BestExplore options in

SetPositionSize

bo = GetBackTesterObject;

e = bo.Equity;No Best Best For advanced users

By ThaiQuants.com 05/10/15