Portfolio backtester  [SOLVED]

Questions about MultiCharts and user contributed studies.
rgranero
Posts: 56
Joined: 26 Jul 2010
Has thanked: 4 times
Been thanked: 1 time

Portfolio backtester

Postby rgranero » 25 Feb 2013

Hi to all,
with this code:

value2=(100000)/c;

if date=1020313 {13/03/2002} and getsymbolname="CAT" then
buy value2 shares next bar at o;

if date=1080319 {19/03/2008} and getsymbolname="AA" then
buy value2 shares next bar at o;
{}

and the portfolio setting like in the image attached, in data 20/03/2008 there is a purchase of AA. But CAT is still in portfoglio and the money earned is not usable.
Then why there' s a purchause on the second stock AA when there is no money available?

I do not understand where I go wrong...

Thanks
Riccardo
Attachments
Setting and result.png
(80.79 KiB) Downloaded 564 times

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Portfolio backtester

Postby Andrew MultiCharts » 25 Feb 2013

Hello Rgranero,
Hi to all,
... in data 20/03/2008 there is a purchase of AA. But CAT is still in portfoglio and the money earned is not usable.
T
Why the earned money are not available?

rgranero
Posts: 56
Joined: 26 Jul 2010
Has thanked: 4 times
Been thanked: 1 time

Re: Portfolio backtester

Postby rgranero » 25 Feb 2013

Because the symbol cat is still in portfolio and the money isn' t available.

I try to explain better:

I start with 100.000,00 usd and buy 1000 stock Z at 10 USD and after 1 years stock Z is at 20 usd and is still portfolio.

Then if I want buy another stock Y I can't buy it because I haven' t money. The stock Z is still in portfolio and the money earned (stock Z from 10 to 20 = +100.000,00) isn't available.

While in backtester the money earned seems to be available.

Thanks

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Portfolio backtester

Postby Andrew MultiCharts » 26 Feb 2013

Current available sum of money is calculated by this formula in Portfolio Backtester:
Portfolio_Equity = InitialCapital + Portfolio_NetProfit + Portfolio_OpenPositionProfit – TotalPotentialRiskCapital

rgranero
Posts: 56
Joined: 26 Jul 2010
Has thanked: 4 times
Been thanked: 1 time

Re: Portfolio backtester

Postby rgranero » 26 Feb 2013

Ok Andrew,

can you help me how to achieve this goal.

I don' t want buy stock AA because stock CAT is still in portfolio.

How can I write it in the code in the first post?

Thanks

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Portfolio backtester  [SOLVED]

Postby Andrew MultiCharts » 27 Feb 2013

You can set a condition in script based on the following keywords:

Code: Select all

Portfolio_InvestedCapital
InitialCapital

rgranero
Posts: 56
Joined: 26 Jul 2010
Has thanked: 4 times
Been thanked: 1 time

Re: Portfolio backtester

Postby rgranero » 28 Feb 2013

Thanks Andrew,

seem works with this solution

Capital to invest:
(InitialCapital +Portfolio_NetProfit-Portfolio_InvestedCapital-Portfolio_OpenPositionProfit)


Thanks!!

Riccardo


Return to “MultiCharts”