Hi!
Sorry if there has already been similiar question. I didn't manage to find such topic.
Is it possible to use partial exits in percent?
For instance,
Entries:
first position is opened after crossing over Price Channel
All further position are opened when the price goes up by 3000 points
Exits:
Once the price goes 3000 points down we should close 30% of all active positions
Here's the code:
CODE:
Please log in to see this code.
It is clear how to close all positions.
But how is it possible to close 33% of all positions?
Thank you in advance!
Size:
Color:
Considering that your system opens multiple positions, makes sense to not complicate things with
SplitPosition.
What is
33% of all open positions? Simply
CODE:
Please log in to see this code.
This gives you the number of positions to exit, or to retain:
CODE:
Please log in to see this code.
Consequently, finish your loop not before you reach the last one (0) -- but before you reach the index of the first position to retain:
CODE:
Please log in to see this code.
Size:
Color:
Eugene,
QUOTE:
What is 33% of all open positions? Simply
Pardon, I forgot to mention that every new position means a specific fixed number of contracts.
For example, every time we buy 30 contracts.
Thus, for instance, we've opened 4 positions. It means that we have 120 contracts. Every time the price goes 3000 points down we sell 30% of all active positions. i.e. 40 contracts. If the price continues to go down we sell 40 contracts again. And if the price goes down one more time, we sell all the remaining contracts.
Thank you for the prompth reply!
Size:
Color:
Size:
Color:
Eugene, everything's clear now!
Thank you for your help!
Size:
Color:
I want to exit all open positions with the codes:
CODE:
Please log in to see this code.
and trades are included in the attached screenshot. When I want to sell All open positions, only positions on one symbol is sold, there still are open positions (on other stocks) left, For example, when ticker 'PCLN' is sold with 'SellAll" on 11/16/2015, the position on 'TXN' which was bought on 9/9/15 is still open until 1/8/2016. why?
Size:
Color:
the screen shot is attached.
Size:
Color:
QUOTE:
I want to exit all open positions
This topic is rather about exiting "33% of all open positions" which is a different subject. Position.AllPositions is a shortcut to exit all positions. If a Position isn't sold it doesn't meet the exit criteria (i.e. the CrossUnder).
Size:
Color: