Open charts for open positions

 

Hi,

is there a function in MT5 or a script that opens for all my open positions (displayed in the Trade window) a Chart (using the default template)?

 

Thank you.

 

Best,

Chrs 

 
zubr:

Hi,

is there a function in MT5 or a script that opens for all my open positions (displayed in the Trade window) a Chart (using the default template)?

 

Thank you.

 

Best,

Chrs 

There is no function by default to do it automatically.

You can write an EA for that using this function

long ChartOpen(

string symbol, // Symbol name

ENUM_TIMEFRAMES period // Period

); 

 
chandra100:

There is no function by default to do it automatically.

You can write an EA for that using this function

long ChartOpen(

string symbol, // Symbol name

ENUM_TIMEFRAMES period // Period

); 

Thank you. 

How can I iterate through my open positions (the Trade window) to get the symbols for ChartOpen? 

 
zubr:

Thank you. 

How can I iterate through my open positions (the Trade window) to get the symbols for ChartOpen? 

PositionsTotal function returns the number of open positions.

int PositionsTotal();

 

 Use a for loop looping from 1 to  PositionsTotal()

 

PositionGetSymbol function returns the symbol corresponding to the open position and automatically selects the position.

string PositionGetSymbol(

int index // Number in the list of positions

); 

Documentation on MQL5: Trade Functions / PositionGetSymbol
Documentation on MQL5: Trade Functions / PositionGetSymbol
  • www.mql5.com
Trade Functions / PositionGetSymbol - Documentation on MQL5
Reason: