I have 4 Short and 4 Long conditions in a single EA that are working fine. Orders are opening , now here is my questions.
Is there a way i can assign a unique identifier to every position that opens so i can track source logic of that order. so that i may tweak individual conditions more?
You don't need to "assign" anything. All orders (and positions and deals) already have a unique identifier attached to them. It is called a "Ticket", which you can retrieve and use as an ID for that particular order (or position or deal).
You can also assign and use a common "Magic Number" to group them so that you can identify and separate them from other EAs or instances of the same EA.
Thanks for the reply.
getting position info is not the issue.
my EA has total 8 if statements. I am trying to see what position was opened by what if statement. so i think if every if statement can add a unique number or code to every order opened i will be able to track the performance of the logic thats working.
getting position info is no the issue.
if (RSI > 20 && ADX > 50)
double price = PRPR;
double sl = SLSL;
double tp = TPTP;
Unfortunately your sample code does exemplify nor explain what you are trying to do. However, after placing the "trade.Buy", you should be checking the result of the trade request with ResultRetCode() and then obtaining the Deal ticket with ResultDeal() which you can then use to track it and obtain further information.
You should not rely on Order Comments at all as brokers can easily change them or even remove them completely! So why suggest such a limited solution when there is already the Ticket Number and/or Magic Number that is the correct way to implement it and is guaranteed to work every time on every broker?
and thats exactly the question brother,
I know a comment can be added to order using positionGetXX command.
if (x=y) // LOGIC 1
if (x+1>y-1) // LOGIC 2
Position is opened using function below by one of the logic above
NOW all i am trying to do is after a position is opened and after its closed either by TP or SL; in the report you can see the reason a position was closed TP or SL.
i just need to know which logic 1 or 2 opened the position.