Hi,
I tried to make additional entries for a symbol during a portfolio simulation.
Am I right that I have to make a completely new entry? Since a simulation
calculates first with only 1 share I am not able to add additional share ... I guess ...
Additonal entries seems to work, so I tried to exit all additional positions
when the first position of a symbol generates an exit:
CODE:
Please log in to see this code.
But that changes the main position list and it generates errors, that the ordering
of this list is wrong ...
What is the best way to accomplish this?
Thx
Gamba
Size:
Color:
Size:
Color:
Eugene, of course, but I want to use it in portfolio simulation, woth multiple symbols.
If I understand it right the code is only for one symbol, because using of
AllPositions will close all my portfolio positions.
Would you pleas answer my questions, that would be point me in the right direction.
Thx
Gamba
Size:
Color:
QUOTE:
But that changes the main position list and it generates errors
You can't use a foreach loop to exit (i.e. remove) a position from the ActivePositions list. Instead, use this design pattern:
CODE:
Please log in to see this code.
Size:
Color:
In addition I have to ask in the main loop if there are further active positions.
After that it seems to work.
CODE:
Please log in to see this code.
So, let's get back to my iniial questions:
1.) I tried to make additional entries for a symbol during a portfolio simulation.
Am I right that I have to make a completely new entry and can not simply add some shares?
2.) The now working exit for all positions of one symboi in a portfolio simulation:
Is this a known technique are there any other best practices for a portfolio?
Or in worst case: Are there any known side effects ...
Thx
Gamba
Size:
Color:
1) Yes, absolutely.
2) Maybe Position.AllPositions?
Size:
Color: