Getting Partial Close to add ticket to array so it does not try to partial close the same trade twice

 
Hello, I asked a question earlier and got enough to write this.
What I'm trying to do is to Trail Stop and Partial Close on a Ticket and only do it once. As currently its closing partially twice.
How do I add the ticket to the array and check if ticket[i] != array then we can move sl and close partial otherwise we cannot.
Code attached. I feel like I'm close but just not getting it yet.
Documentation on MQL5: Integration / MetaTrader for Python / order_calc_margin
Documentation on MQL5: Integration / MetaTrader for Python / order_calc_margin
  • www.mql5.com
order_calc_margin - MetaTrader for Python - Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Files:
 
matheau: How do I add the ticket to the array and check if ticket[i] != array then we can move sl and close partial otherwise we cannot.
CArrayLong o_array;
⋮
void  ApplyTrailingStop() {
CArrayLong *array=new CArrayLong;

which array are you adding to?

 
William Roeder #:

which array are you adding to?

William Roeder #:

which array are you adding to?

Adding to "array" and adding the ticket I'm just not sure how to do it properly.
https://www.mql5.com/en/docs/standardlibrary/datastructures/carraylong/carraylongadd

This line
Trying to add it to this array. Then check if ticket is there before each call if its not run the script if not dont.
array.Add(ticket); // Adds ticket to the array
 (PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY  && mainProfit >= tradeProfit && !array )
Something like this. I'm just stuck.
Documentation on MQL5: Standard Library / Data Collections / CArrayLong / Add
Documentation on MQL5: Standard Library / Data Collections / CArrayLong / Add
  • www.mql5.com
Add(long) - CArrayLong - Data Collections - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
matheau #: Adding to "array"

Array is a pointer that you loose when the function returns. Memory leak and you are not remembering anything.