Portfilio Trader Driving Me Crazy

Questions about MultiCharts and user contributed studies.
StefanoSF
Posts: 116
Joined: 19 Aug 2012
Location: San Francisco
Has thanked: 23 times
Been thanked: 30 times
Contact:

Portfilio Trader Driving Me Crazy

Postby StefanoSF » 23 Feb 2015

I'm testing a simple MA Cross strategy. There are 2 signals. "Buy" if MA is above 50 day MA and "Sell" if crosses below. There are 10 ETF's for the signal to choose from.

I have two issues:

1) In signal Properties: "Cash Per Trade" is set to $20,000 (rounding down to nearest 10 with min contracts= 100). Non of these rules are being implemented when Backtesting as many trade sizes are below 100 and not rounding down to nearest 10. Many positions show "1" share. Why?

2) The number of positions should grow as the portfolio value increases. With an initial Portfolio Capital of $100k and Cash Per Trade set to $20k, five or less positions can be opened. However, as the portfolio value grows to $300k the number of positions is still stuck at below five with each having a value of under $20,000? What am I doing wrong?

Image
Attachments
Port-PositionSizing.png
(173.99 KiB) Downloaded 988 times

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Portfilio Trader Driving Me Crazy

Postby Henry MultiСharts » 24 Feb 2015

Hello Stefano,

Our engineers are currently analyzing your inquiry. I will get back to you in case any additional information is required.

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

Re: Portfilio Trader Driving Me Crazy

Postby orion » 24 Feb 2015

It is because you have set the MarginPerContract to 100% and Max Potential Loss to 100%. The workings of the portfolio risk manager logic is explained in the pseudocode posted in this thread. However, note that there are still some areas that are not fully explained such how the portfolioOrdersAllowed variable works (Andrew says "the formula is much more complicated" in post #7).

I use the PT as my primary application. Since how some of these settings work are still a bit of a black box due to lack of proper documentation, I avoid using all these settings. I set both MarginPerContract and MaxPotentialLoss to 0 to ensure they do not interfere with my position sizing. I also use explicit order sizes in my code to override the order sizes from the Properties dialog. Bottom line, do not use these settings and use explicit order sizes in your code and you will love the PT instead of it driving you crazy.

StefanoSF
Posts: 116
Joined: 19 Aug 2012
Location: San Francisco
Has thanked: 23 times
Been thanked: 30 times
Contact:

Re: Portfilio Trader Driving Me Crazy

Postby StefanoSF » 26 Feb 2015

I've spent all day trying to do the following with no luck:

Position size a PT strategy so that it allocates 20% of available invest-able capital to each position and rounds down the shares to the nearest 100 shares.

I tried the following function in my script with no luck:
- NumUnits(Amount, MinLot)
- PortfolioEquity
- GetBDCashBalance
- GetBDDayTradingBuyingPower
- GetRTCashBalance

There must be an easy way. Perhaps using PT's Money Management Signal feature??

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

Re: Portfilio Trader Driving Me Crazy

Postby orion » 26 Feb 2015

As I mentioned in the previous post, I do not rely on PT for doing any of my position sizing because even after spending a fair amount of time and effort in trying to understand the workings of its risk manager, there are still pieces of its functionality that are a black box and I don't like operating with black boxes.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Portfilio Trader Driving Me Crazy

Postby Henry MultiСharts » 27 Feb 2015

Hello Stefano,

Our engineers have studied your first question. Here Portfolio Trader works as expected.
1) Decreasing the number of contracts.

Upon each attempt to enter a position certain rules of money management («Money Management Settings») are checked for compliance. Strategy generates one entry order per instrument upon next calculation on all instruments. Verification is performed before submitting the order, regardless of the number of contracts specified (any «Trade Size» mode): how much capital we risk if we enter into this position with this order and if specified money management rules are complied.

The maximum potential loss on the transaction PotentialRiskCapital (in selected currency) is calculated as:
PotentialRiskCapital = Quantity*(MaxPotentialLossPerContract+MarginPerContract + CommVpc + SlippageVpc) + CommVpt + SlippageVpt
• Quantity – amount of contracts;
• CommVpt – Commission value in per Trade mode. If the other mode is selected then value =0.
• SlippageVpt – Slippage value in per Trade mode. If the other mode is selected then value =0.
• CommVpc – Commission value in per Contract mode. If the other mode is selected then value =0.
• SlippageVpc – Slippage value in per Contract mode. If the other mode is selected then value =0.

Then money management rules are verified:
• Total amount of risk capital (PotentialRiskCapitalForSymbol) per symbol specified in percent settings («Max % Capital at Risk Per Position: %») from the current “clean” Portfolio_Equity (TotalPotentialRiskCapital not taken into account) is not exceeded;
• TotalPotentialRiskCapital taking into account the additional risk specified in percent settings («Exposure: %») from current “clean” Portfolio_Equity (TotalPotentialRiskCapital not taken into account) OpenPositionProfit is not exceeded;
• “clean” Portfolio_Equity = InitialCapital + Portfolio_NetProfit + Portfolio_OpenPositionProfit is not exceeded;

MaxPotentialLossPerContract – the maximum amount of risk capital per contact in $.
Calculation is based on the following formula:
MaxPotentialLossPerContract = (OrderPrice*BigPointValue) * MaxPotentialLossPerContractPrcnt / 100

• OrderPrice – order price (if market order then «Open» of the order sending bar);
• BigPointValue – price per unit in $ (is taken from symbol settings in Quote Manager);
• MaxPotentialLossPerContractPrcnt - max amount of risk capital specified in %;

If any of the limitations is not complied then the amount of contracts for the order (NumberOfContracts) is decreased for the same value to respect all limitations.

It can be demonstrated on the following example.
Let’s analyze the first trade only to keep the calculations simple:
InitCapital= 1000
FixedShares= 1000
MaxPotentialLossPerContractPrcnt = 1%
then MaxPotentialLossPerContract = 32,91 * 1% = 0,3291
PotentialRiskCapital = 1000 Contract * 0,3291 = 329,1
“Clean” Portfolio_Equity = InitCapital= 1000 (because it is the first trade)
TotalPotentialRiskCapital = PotentialRiskCapital = 329,1 (because there is one instrument in the Portfolio).
Both conditions are met and the trade size is limited by FixedShares= 1000 only.

2) MaxPotentialLossPerContractPrcnt = 50%
then MaxPotentialLossPerContract = 32,91 * 50% = 16,455
PotentialRiskCapital = 60 Contract * 16,455 = 987,3
“Clean” Portfolio_Equity = InitCapital= 1000 (because it is the first trade).
Then the amount of contracts (60) for the first trade matches properly.

3) MaxPotentialLossPerContractPrcnt = 100%
then MaxPotentialLossPerContract = 32,91 * 100% = 32,91
PotentialRiskCapital = 30 Contract * 32,91 = 987,3
“Clean” Portfolio_Equity = InitCapital= 1000 (because it is the first trade)
Then the amount of contracts (30) for the first trade is matches properly.

2) The number of positions should grow as the portfolio value increases - that is correct and we have made sure that it works. If you consider that the strategy should buy but it does not - please check the current price * minimum number of shares/contracts you have specified. If this value is > than CashPerTrade then the strategy will not generate an order. If this value is < than CashPerTrade then the strategy can generate an order that will be checked for compliance with money management rules described above.
Attachments
portfolio_MM.zip
(314.81 KiB) Downloaded 193 times


Return to “MultiCharts”