Stop loss based on total open profit of the portfolio

Questions about MultiCharts and user contributed studies.
The9000
Posts: 59
Joined: 24 Oct 2015
Has thanked: 2 times
Been thanked: 4 times

Stop loss based on total open profit of the portfolio

Postby The9000 » 07 Nov 2015

Hi,

I've read through the Wiki on the keywords for the Portfolio Trader and the money management signal. Several times. After reading it and searching these forums, I believe my portfolio level stop loss code belongs in the strategy and not in the money management signal.

I have a portfolio of 10 symbols and 1 strategy. The strategy runs on 2 minute bars.

What I'm looking to do is close all positions in the portfolio when the total open profit falls below a certain level. I have a stop loss in my code for the individual instrument and a second exit based on the total open profit. My code is:

Code: Select all


if marketposition=1
and -1*pmms_strategy_openprofit(0) > PortfolioStop*.01*Portfolio_Equity
then
sell ("PortStopLX") next bar at market;

if marketposition=-1
and -1*pmms_strategy_openprofit(0) > PortfolioStop*.01*Portfolio_Equity
then
buytocover ("PortStopSX") next bar at market;
PortfolioStop is an input and is a the percentage value at which all open positions should be closed out. However when I run an optimization on the PortfolioStop value, it has no effect on the results.

What am I missing?

The9000
Posts: 59
Joined: 24 Oct 2015
Has thanked: 2 times
Been thanked: 4 times

Re: Stop loss based on total open profit of the portfolio

Postby The9000 » 13 Nov 2015

There has to be a way to know the current total profit of all open positions for the strategy? I can't be the first person to have this idea.

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

Re: Stop loss based on total open profit of the portfolio

Postby Henry MultiСharts » 20 Nov 2015

Hello The9000,

Please check Portfolio_NetProfit and Portfolio_OpenPositionProfit.


Return to “MultiCharts”