Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Ok maybe i found a way, thank you ABCTG for support.
Put it into your individual signals:
input:ptf(true);
if (mp 0 and ...) then begin
if (ptf = true) then pmm_set_my_named_num("test",1);
buy ....
end;
Then this is the Portafoglio …
But it doesn't work at all for me.
I have also tested to include this code in my strategy signal as a condition:
_____________
Portfolio_CurrentEntries < 10
_____________
Unfortunately when several signals appear at the same day the strategy applies them all (if it is less than 10 signals in market the day before) - which means that in reality it can be a lot more positions than 10 iin the market simultaneously.
you will likely have to evaluate the number of signals that want to enter at the current date within the Money Management signal and block those that you don't want to get filled. Otherwise there wouldn't be a way to stop the entries anymore.
Something along the line of the below should work, but it will require some programming:
1. When the entry conditions in your signal are true, send a value (+1 for example) to the money management signal.
2. If the conditions are not true, send a value of 0 for example.
3. In the money management signal you'd block all entries first. Then you
can loop over all symbols in the portfolio and check how many individual signals want to enter.
One thing to decide here for you would be how to handle situations where more signals want to enter than the number of open positions you want to allow i.e. do you deal with that on a first come first serve basis or do you want to apply a ranking. If it's a ranking, the ranking would have to be computed in the individual signal and the result send to the money management, too.
4. Depending on the above method you choose, you'd either allow the entries for the symbols until you allowed number of positions is reached. If you apply a ranking you'd gather the ranking values for all symbols that want to enter in step 3.. Once you have all, sort them and let only the top (or bottom or what ever your ranking is) X symbols pass. Where X is the number of positions that can still be filled i.e. Max allowed positions - current open positions.
When I say send to the money management this involves the special portfolio reserved words that start with pmm_ and pmms_ and the help files provide a good start on these. You might also want to explore the three build in money management signals together with the PDF that explains them in depth. This will help a lot.
I have been able to come up with a signal base and MM signal that limits the number of position simultaneously to 1. But not to 10. Most of the help I got from this thread:
there is any easy way through Multicharts Portfolio Trader to set a Max Number of Open Position (like in amibroker) to reduce account size required in a TS portfolio ?
For example i would like, in a portfolio of 25 system, to limit the max …
The issue is how to get the variable to change - so that it adds "1" to the "pmm_set_my_named_num" everytime a new position enters the market and at the same time subtracts "1" from the "pmm_set_my_named_num" everytime a position closes.
you are welcome. By the way you can show your appreciation for a post on futures.io by clicking the "Thanks" button next to it.
As a general tip and in case you don't do that already, I'd suggest to start commenting your code. This will make your life a lot simpler down the road. Imagine going back to a code you wrote month or years ago - without comments it will take you so much longer to find your way around again. This can also help you finding errors in your code, when your comment says this part should do xyz and when you compare the code you find that it does in fact uvw.
I don't understand why you'd want to add or subtract values to a variable that you send with pmm_set... - in my opinion it would be less error prone to only have the signal code change this value and have the money management signal read those values only.
Why did you add this code snippet, that blocks all further entries when you are in at least one position?
From your MM code it appears you might want to add the following:
1. Before you loop over all signals, check how many are in positions already. Your code already contains the array
for that, but it seems you strapped this part. You can look into the three build in Portfolio Trader examples in Multicharts, at least one of them demonstrates how to do that.
2. Now you can compute how many positions you have and arrive at a number of how many you still want to allow.
3. You will most likely need two loops here. During the first loop check the symbols that want to enter (you already do that) and check if they are already in a position (you'd need to add that part). If they want to enter and are not yet in a position, save the strategy index number in an array (which you need to create, and clear each time before you start the loop).
4. In you second array you need to loop through the array that holds the symbols that want to enter and only allow the number of positions that are still free (which is what you computed under 2.). If there are less symbols to enter in the array than allowed positions, there would be no need to filter them. If there are more symbols than "free spots" you need to come up with code to handle this situation i.e. only allow X out of the total number that wants to enter - for example either allow them on a first come, first served base or apply a ranking so you can decide which to prefer.
The part I have added in the code since last post should do this I think.
I have checked throught all three example MM codes in Multicharts but I still have a hard time trying to create code for these steps:
the task you are trying to accomplish is definitely a bit more complex and depending on your level of programming experience can give you "a hard time" for sure.
You are dealing with "advanced" concepts in Multicharts here and someone without a solid foundation of the basics (speaking in general terms here and not geared towards
you, as I don't know your programming experience in Multicharts) might run into problems here easily.
Regarding the points, you already have the most part for 2. covered (although only for long positions).
Doesn't the variable inLong hold the number of long positions you are in at the moment?
If that is the case and as you know you want to enter 10 positions at max (which I'd suggest to make an input), you should be able to compute how many spots are still left.
Now you can start with 3.. Create the array that holds the strategy index numbers for the symbols to enter and build
the first loop as described: