How to limit # of active positions?
Author: trader rog
Creation Date: 10/20/2009 10:24 AM
profile picture

trader rog

#1
I am trying to limit the number of positions to 10 longs and 10 shorts, but when I run the code below, the results show 10 total positions instead. I have the slider under strategy parameters set to 20. I have tried using 5% equity for position size, and a $5,000 fixed dollar amount with $100,000 starting capital and get the same results for both. Thanks to anyone that can offer help.

CODE:
Please log in to see this code.
profile picture

ss161

#2
i think you are leaving out brackets around an if statement and so are not getting the result that you think you are getting.

your code:
CODE:
Please log in to see this code.


here's what i think you want:
CODE:
Please log in to see this code.


assuming this is right, since i only eyeballed it. you need to also apply the same fix to the short side
profile picture

Eugene

#3
CODE:
Please log in to see this code.

This could be wrong, but shouldn't the activelongs/activeshorts rule be checked after already having checked for the right symbol?
CODE:
Please log in to see this code.
profile picture

ss161

#4
i think the code should probably be restructured a bit, but i think this works:
CODE:
Please log in to see this code.

profile picture

trader rog

#5
I tried using both suggestions and it seems that Steve's solution does the trick. Thanks to Steve and Eugene for your help. Much appreciated.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).