Portfolio Trader Rebalanced

Questions about MultiCharts and user contributed studies.
hatman
Posts: 4
Joined: 14 Feb 2015

Portfolio Trader Rebalanced

Postby hatman » 14 Feb 2015

Hello,

I am making a portfolio strategy. What I want is to buy some sares and then, I want to make partial closes and partial opens, without closing all the position.

For example:
First Trade: buy 100 Apple Shares buy 200 Google Shares
Second Trade: buy 10 Apple Shares sell 15 Google Shares (sell, no shortsell)
Third Trade: buy 20 Apple Shares buy 20 Google Shares
Fourth Trade: sell 5 Apple Shares buy 30 Google Shares

Final Portfolio: 125 Apple Shares 235 Google Shares

I'm implementing this strategy with a Portfolio Trader Signal and a Portfolio Trader MM Signal

I have read the documentation but I need some help.

Thank you very much

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Portfolio Trader Rebalanced

Postby orion » 14 Feb 2015

Each row of PT is an independent strategy. So each row of PT behaves just like a chart. The PMM signal is an extra feature of PT and you do not need to use it. So for your purpose insert two symbols (GOOG and AAPL), insert your signals against them, and hit backtest.

hatman
Posts: 4
Joined: 14 Feb 2015

Re: Portfolio Trader Rebalanced

Postby hatman » 14 Feb 2015

I do need it. Because I looking for rebalance the portfolio. I want to have the same dollar amount in each symbol. It isn't just buy or sell...

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Portfolio Trader Rebalanced

Postby orion » 14 Feb 2015

I do need it. Because I looking for rebalance the portfolio. I want to have the same dollar amount in each symbol. It isn't just buy or sell...
From my understanding of what you are looking to do, you don't need the PMM signal for doing equal position sizing or portfolio rebalancing. You can simply have each individual strategy look at the total portfolio account value and take action. In addition, if you want strategies to cooperate for maintaining a market-neutral position, you can still achieve it via built in global variables in PT. See pmm_set_global_named_num and friends.

hatman
Posts: 4
Joined: 14 Feb 2015

Re: Portfolio Trader Rebalanced

Postby hatman » 15 Feb 2015

I have tried what you said.
This is my code:

Code: Select all

vars:
numberofstrat(0),
numsend(0),
numcontr(0);

numberofstrat = pmms_strategies_count;

numcontr = Floor((Portfolio_Equity / numberofstrat) / Close);
numsend = absvalue (currentcontracts - numcontr);

if (currentcontracts < numcontr) then begin
buy numsend shares next bar at market;
end
else if (currentcontracts > numcontr) then begin
sell numsend shares next bar at market;
end;

print(Date, " ",symbol, " ", currentcontracts, " ", numcontr, " ", numsend);
I have tested this code with three symbols: SPY, CAT and AAPL.
The output created by the print for the first four days is the following:

1130503.00 AAPL 0.00 518.00 518.00
1130503.00 CAT 0.00 383.00 383.00
1130503.00 SPY 0.00 206.00 206.00
1130506.00 AAPL 518.00 509.00 9.00
1130506.00 CAT 383.00 383.00 0.00
1130506.00 SPY 206.00 207.00 1.00
1130507.00 AAPL 509.00 516.00 7.00
1130507.00 CAT 383.00 376.00 7.00
1130507.00 SPY 206.00 208.00 2.00
1130508.00 AAPL 509.00 514.00 5.00
1130508.00 CAT 376.00 377.00 1.00
1130508.00 SPY 206.00 208.00 2.00

My conclusions are, the entry is ok, the first rebalanced is ok, but then it isn't right.

What could be the problem??

Thank you very much

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Portfolio Trader Rebalanced

Postby orion » 15 Feb 2015

From the output you printed it seems even the first rebalance didn't work. And the problem most likely has to do with your position limits settings.


Return to “MultiCharts”