Close PT Orders at Open

Questions about MultiCharts and user contributed studies.
TradingPro
Posts: 20
Joined: 21 Dec 2009

Close PT Orders at Open

Postby TradingPro » 19 Dec 2016

PMMS_Strategy_Close_Position appears to close orders at the close of the current bar.
How would it be possible to modify this to have Portfolio Trader positions close at the open of the following bar?

TradingPro
Posts: 20
Joined: 21 Dec 2009

Re: Close PT Orders at Open

Postby TradingPro » 20 Dec 2016

MC staff - Is this possible with Portfolio Trader?

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

Re: Close PT Orders at Open

Postby Henry MultiСharts » 21 Dec 2016

Hello TradingPro,

We will check it and get back to you.

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

Re: Close PT Orders at Open

Postby Henry MultiСharts » 22 Dec 2016

Hello TradingPro,

Portfolio Money Management Signal needs to know the events of all data series therefore it is called on each new tick (it runs in IOG).
PMMS_Strategy_Close_Position can close the position intrabar, not only on bar close. Position will be closed on the next calculation following the one when PMMS_Strategy_Close_Position was called.
In order to close the position at bar open you can call PMMS_Strategy_Close_Position when barstatus=0.

TradingPro
Posts: 20
Joined: 21 Dec 2009

Re: Close PT Orders at Open

Postby TradingPro » 23 Dec 2016

Thank you for you assistance Henry.
I was hopeful that the advice you provided would be sufficient however I am currently stuck with positions not closing at al right now.

Referring to the Portfolio Trader Strategy Examples I can demonstrate precisely what is needed here: https://www.multicharts.com/trading-sof ... y_Examples

In the Portfolio_Rotation_MM Signal strategies which are in position, but are not among the best according to the indicator indexes are forced to close as follows:

Code: Select all

For IDX = 0 To InLong - 1 Begin
Value1 = StrategiesLong[IDX];
If Value1 >= 0 Then Begin
PMMS_Strategy_Close_Position(Value1);
If Use_Logging Then Print("Long Exit: ",PMMS_Strategy_Symbol(Value1));
End;
End;
This code closes the positions at the close of the current bar instead of the open of the following bar which is required.

Following your advice above, the following modification to the code above does not close ANY positions:

Code: Select all

For IDX = 0 To InLong - 1 Begin
Value1 = StrategiesLong[IDX];
If Value1 >= 0 and BarStatus(1) = 0 Then Begin
PMMS_Strategy_Close_Position(Value1);
If Use_Logging Then Print("Long Exit: ",PMMS_Strategy_Symbol(Value1));
End;
End;
It appears that Value1 >= 0 and BarStatus(1) = 0 will always return FALSE
How could we get the Portfolio_Rotation_MM Signal in the Portfolio_Trader_Strategy_Examples to close all positions at the open of the next bar?
Last edited by TradingPro on 23 Dec 2016, edited 1 time in total.

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

Re: Close PT Orders at Open

Postby TJ » 23 Dec 2016

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

TradingPro
Posts: 20
Joined: 21 Dec 2009

Re: Close PT Orders at Open

Postby TradingPro » 23 Dec 2016

Thank you for the tip TJ (I've not visited this forum for approx 6 years now)

Over to MC staff for a solution please.

TradingPro
Posts: 20
Joined: 21 Dec 2009

Re: Close PT Orders at Open

Postby TradingPro » 08 Jan 2017

MC staff could we receive a response please.

TradingPro
Posts: 20
Joined: 21 Dec 2009

Re: Close PT Orders at Open

Postby TradingPro » 13 Jan 2017

MC staff - Is this possible with Portfolio Trader?
Please respond

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: Close PT Orders at Open

Postby Angelina MultiСharts » 17 Jan 2017

Hello TradingPro,

BarStatus(1) = 0 is possible only for the realtime calculation. For the calculation on historical bars BarStatus(1) will always return 2, as all the bars are closed.
Last edited by Angelina MultiСharts on 18 Jan 2017, edited 1 time in total.

TradingPro
Posts: 20
Joined: 21 Dec 2009

Re: Close PT Orders at Open

Postby TradingPro » 17 Jan 2017

Thank you for your reply Angelina.

So going back to the original requirement:

PMMS_Strategy_Close_Position appears to close orders at the close of the current bar.
How would it be possible to modify this to have Portfolio Trader positions close at the open of the following bar?

... is there really no way for Portfolio Trader to do this?

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: Close PT Orders at Open

Postby Angelina MultiСharts » 08 Feb 2017

TradingPro,

Unfortunately, it is not possible for historical calculations.


Return to “MultiCharts”