Getting the symbol of an open position and comparing it to the symbol of the chart the expert advisor is attached to

 
Hello programers, how can i get the symbol of an open position and compare it to the symbol of the chart my ea is attached to. I'd really appreciate the help.
 
Edwin Tempah: Hello programers, how can i get the symbol of an open position and compare it to the symbol of the chart my ea is attached to. I'd really appreciate the help.

Have you been reading the documentation? If you just scan the Trade Functions you can quickly see the answer:

Or if you already have a ticket number selected, then use PositionGetString() with POSITION_SYMBOL.

Documentation on MQL5: Trade Functions / PositionGetSymbol
Documentation on MQL5: Trade Functions / PositionGetSymbol
  • www.mql5.com
PositionGetSymbol - Trade Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Fernando Carreiro #:

Have you been reading the documentation? If you just scan the Trade Functions you can quickly see the answer:

Or if you already have a ticket number selected, then use PositionGetString() with POSITION_SYMBOL.

i must have missed it but i had only tried the POSITION_SYMBOL without first getting the ticket number and it kept returning the implicit conversion from number to string error. Thanks it has worked now. 

 
Edwin Waithaka Gichigi #:

i must have missed it but i had only tried the POSITION_SYMBOL without first getting the ticket number and it kept returning the implicit conversion from number to string error. Thanks it has worked now. 

Can you share the portion of the code that is now working that you had trouble with?
Reason: