thanks for the reply and for the information on virtual position reporting. I will try to implement your suggestion for virtual position reporting. For now, I am attaching the current file that seems to work. These are the modifications (I tried to keep them tidy, but they are not as good looking as your code - please note, I have global variable for tickets which I know it's bad practice but I am not too familiar with array handling in MT4, in particular how to pass back an array from a function call):
1. Added function MagicFromSymbol() to auto calculate a magic number depending on the current symbol. I wanted to include this in order send, but then I realised that FST sends an argument with magic number information, so for the moment my MagicNumber is not being used. I would like to know your opinion about this. The idea was to include checking based on magic on each order before modify or close, to make sure it belongs to the EA (in case we are also trading other EA or manually on the same account and symbol).
2. Added array int tickets to hold all the tickets of the EA.
3. Added string orderComment to allow me to visually know which trades belong to this EA on the positions log in MT4.
4. In GetPositionTicket(string symbol) removed the check for positionTicket != 0 so that we can have more than 1 position without reporting error. The same in OpenNewPosition () function.
5. Modified CloseCurrentPosition() to close all positions on this symbol (hopefully later can include check against magic too as I mentioned in (1)).
6. In ClosePosition() I added color of arrow to visually show in MT4 where the position was closed.
7. In AddToCurrentPosition() removed the call to close position function.
8. In ReduceCurrentPosition() I removed call to open new position, and modified the number of lots for the close position function (I haven't tested this).
9. In ModifyPosition() for Stop Loss and Take Profit, cycling through all orders to modify them (haven't tested this).
10. In AdjustTrailingStop() same as (9) above.
11. Added function GetPositionTickets(string symbol) to populate the array of tickets (I should have modified this to return void really...)
12. In OpenNewPosition() I changed the OrderSend to send 0 TP SL and modify them with OrderModify, because my broker requires this. I added 10 retries to open order with Sleep(500), error checking for Context Busy. Also I wanted to add some code to check for invalid stop loss/TP, because it can happen sometimes (especially with the confusion between 4 and 5 digits brokers or in case there are incorrect settings for the instrument in FST), but this code is commented out for now cause I haven't had the chance to check it.
13. Added function CountOpenOrders()
I am sure my code can be improved and things can be done better, maybe some more error checking, but I hope it helps a bit.