Hello,
I'm trying to work on an EA that will help hedge open orders. I would like to be able to close only a portion of the hedge orders now and then - all the negative ones and as few positive ones as possible so as to close these down at break even or a small profit while keeping as many profitable hedge orders open as possible incase the move against my primary orders actually continues (therefore I don't want to close ALL hedge orders if price looks like it might be continuing the main trend until that is crystal clear).
However, I'm not sure how to easily work with the open orders. I would like to track these in a multidimensional array that I can sort by price, and then move up the array starting with the negative hedge orders and totaling the profit until it is breakeven or positive - then close only those orders down while keeping any additional hedge orders open.
But I'm not sure how to easily keep track of the values. Is there a way to easily store the order info (price, profit, ticket #) in a multidimensional array, that if sorted, will keep the info inline across the values? That is - if I sort the array on price, will it keep the ticket #'s associated with those prices?
Is there anywhere I can go that clearly talks about multidimensional arrays and sorting them, ... I've only seen info on sorting single arrays.
Or, if someone has code that can help do what I'm trying to do - I'd appreciate that as well.
Thanks for any input!
I'm trying to work on an EA that will help hedge open orders. I would like to be able to close only a portion of the hedge orders now and then - all the negative ones and as few positive ones as possible so as to close these down at break even or a small profit while keeping as many profitable hedge orders open as possible incase the move against my primary orders actually continues (therefore I don't want to close ALL hedge orders if price looks like it might be continuing the main trend until that is crystal clear).
However, I'm not sure how to easily work with the open orders. I would like to track these in a multidimensional array that I can sort by price, and then move up the array starting with the negative hedge orders and totaling the profit until it is breakeven or positive - then close only those orders down while keeping any additional hedge orders open.
But I'm not sure how to easily keep track of the values. Is there a way to easily store the order info (price, profit, ticket #) in a multidimensional array, that if sorted, will keep the info inline across the values? That is - if I sort the array on price, will it keep the ticket #'s associated with those prices?
Is there anywhere I can go that clearly talks about multidimensional arrays and sorting them, ... I've only seen info on sorting single arrays.
Or, if someone has code that can help do what I'm trying to do - I'd appreciate that as well.
Thanks for any input!