Limiting the number of entries in Portfolio Backtester ?  [SOLVED]

Questions about MultiCharts and user contributed studies.
Aston01
Posts: 21
Joined: 24 Oct 2013

Limiting the number of entries in Portfolio Backtester ?

Postby Aston01 » 27 Dec 2013

I know I can use Portfolio_CurrentEntries to determine the number of open positions within a portfolio, but with multiple strategies is there a way to limit the open positions specific to that strategy?

For instance I am backtesting two separate strategies (on multiple instruments) within a portfolio that are inversely correlated and I would like to limit each strategy to just one open position. I have tried using Portfolio_CurrentEntries < 3 , but at times I get two trades in one strategy and none on the other.

Anyway around this in Portfolio Backtester ?

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

Re: Limiting the number of entries in Portfolio Backtester ?

Postby Henry MultiСharts » 30 Dec 2013

Aston01, unfortunately there is no reserved word to limit the amount of entries per strategy at the moment. This is something that will be added in MultiCharts 9.0.

waveslider
Posts: 222
Joined: 16 Oct 2011
Has thanked: 66 times
Been thanked: 20 times

Re: Limiting the number of entries in Portfolio Backtester ?

Postby waveslider » 27 Oct 2017

I am aware of "Portfolio_CurrentEntries", but this will not limit the strategy from entering 10 new entries on one day. For example if it goes into the day with less than 3 entries, the strategy may open 10 new positions. So their needs to be a way to limit the number of new entries on one day. Any ideas of a work around?

User avatar
Anna MultiCharts
Posts: 560
Joined: 14 Jul 2017
Has thanked: 42 times
Been thanked: 140 times

Re: Limiting the number of entries in Portfolio Backtester ?

Postby Anna MultiCharts » 07 Nov 2017

Hello, waveslider!

I’m afraid we haven’t introduced any keyword for limiting entries.
If you need to limit the number of entries for the day, you can compare the value returned by Portfolio_CurrentEntries with the one you need (10, as in your example), and make so that the entry orders are not generated when the condition Portfolio_CurrentEntries < 10 is not true.

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Limiting the number of entries in Portfolio Backtester ?

Postby ABC » 14 Nov 2017

waveslider,

you can accomplish this using a portfolio money management signal and only let the number of entry orders pass that you want to allow.

Regards,

ABC
I am aware of "Portfolio_CurrentEntries", but this will not limit the strategy from entering 10 new entries on one day. For example if it goes into the day with less than 3 entries, the strategy may open 10 new positions. So their needs to be a way to limit the number of new entries on one day. Any ideas of a work around?

waveslider
Posts: 222
Joined: 16 Oct 2011
Has thanked: 66 times
Been thanked: 20 times

Re: Limiting the number of entries in Portfolio Backtester ?

Postby waveslider » 14 Nov 2017

Thanks ABC, I thought so too but was unable to do it. Can you give me a clue as to which signal would help?

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Limiting the number of entries in Portfolio Backtester ?

Postby ABC » 14 Nov 2017

waveslider,

the "Portfolio Rank MM Signal" and documentation should get you going.

Regards,

ABC

waveslider
Posts: 222
Joined: 16 Oct 2011
Has thanked: 66 times
Been thanked: 20 times

Re: Limiting the number of entries in Portfolio Backtester ?  [SOLVED]

Postby waveslider » 14 Nov 2017

thanks!

waveslider
Posts: 222
Joined: 16 Oct 2011
Has thanked: 66 times
Been thanked: 20 times

Re: Limiting the number of entries in Portfolio Backtester ?

Postby waveslider » 08 Dec 2017

Still running into issues with this. Here is some code I tried:

Code: Select all

variables: inLong(0), inShort(0);
arrays: strategiesLong[](-1), strategiesShort[](-1);
inLong = pmms_strategies_in_long_count(strategiesLong);
inShort = pmms_strategies_in_short_count(strategiesShort);
Then I say something like :

Code: Select all

if inlong+inshort<3 then buy this bar;
Still will get multiple entries on the bar. This is because Portfolio trader doesn't know how many entries it has already made on the current date.

How can I track how many entries have been made so far on the current bar?

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Limiting the number of entries in Portfolio Backtester ?

Postby ABC » 13 Dec 2017

waveslider,

from your code snippet it appears you are trying to control the number of entries in the entry strategy. This will most likely not work, as too many entries on different symbols at the same time could go beyond your position limits. Take a look at how the build in "Portfolio Rank MM Signal" only allows entries for the remaining available spots. You would have to take a similar approach and control the entries within a Money Management signal.

Regards,

ABC


Return to “MultiCharts”