Close all open positions with Money Management Signal & PT

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

Close all open positions with Money Management Signal & PT

Postby hatman » 26 Oct 2015

Hello,

How can I close all open positions within the Portfolio Trader with a Money Management signal?

What I need is to make a portfolio stop loss, for example, when the portfolio is 5000 $ close all the positions.

I have another question and is what does Portfolio_CurrentEntries measures? Is the current open positions? The new orders sent by the strategies or is current open (previous to the last order send)?

Best regards,
Hatman

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Close all open positions with Money Management Signal &

Postby TJ » 26 Oct 2015

Hello,
::
I have another question and is what does Portfolio_CurrentEntries measures?
::
Before you go any further,
please get yourself acquainted with the Wiki.


Go to the "Support" tab at the top of this page,
click on the Wiki,
go to #8 PowerLanguage Keyword Reference

look under [+] Portfolio Strategy Position‎ (5)
You have everything you need there.

waldem
Posts: 115
Joined: 18 Nov 2013
Has thanked: 3 times
Been thanked: 4 times

Re: Close all open positions with Money Management Signal & PT

Postby waldem » 31 May 2018

hallo, i reply to this old topic because is still not clear to me if is possible to program portfolio setstoploss at 1000$; if today loss is more than 1k i will see only 1k in backtest. i mean in backetst only, not in realtime.

i have tried this code from Wiki but i see no changes; this should stop loss at -1k.
maybe some other settings wrong?

Code: Select all

inputs: StopLossPcntsOfPortfolio(1),
ProfitTargetPcntsOfPortfolio(0.1);
variable: value(0);
setstopposition;
value = StopLossPcntsOfPortfolio * 0.01 * 100000;
setstoploss(convert_currency(datetime[0], portfolio_CurrencyCode, SymbolCurrencyCode, value ));
Last edited by waldem on 31 May 2018, edited 2 times in total.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Close all open positions with Money Management Signal & PT

Postby TJ » 31 May 2018

See post #1 and post #2
viewtopic.php?t=11713


ps. see also post #5

waldem
Posts: 115
Joined: 18 Nov 2013
Has thanked: 3 times
Been thanked: 4 times

Re: Close all open positions with Money Management Signal & PT

Postby waldem » 31 May 2018

here the code.

Code: Select all

inputs: StopLossPcntsOfPortfolio(1),
ProfitTargetPcntsOfPortfolio(0.1);
variable: value(0);
setstopposition;
value = StopLossPcntsOfPortfolio * 0.01 * 100000;
setstoploss(convert_currency(datetime[0], portfolio_CurrencyCode, SymbolCurrencyCode, value ));


Return to “MultiCharts”