MQL5 getting the number of open positions for a specific symbol

 
Hi programmers, ive been trying to figure out a way of getting the number of open positions for a specific symbol in an ea for example the number of open positions in USDCHF, does anyone have an idea i'd appreciate any idea on how to start
 

Here are all position listed: https://www.mql5.com/en/docs/function_indices.

Search (Ctrl-F) for "open posit" and you'll find PositionsTotal()

Documentation on MQL5: List of MQL5 Functions
Documentation on MQL5: List of MQL5 Functions
  • www.mql5.com
List of MQL5 Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Start with a query for number of open positions, then make a for loop that goes through every position and compares the Symbol with the one you want. Go to documentation and look for functions list. Look for functions that start with Position. 
Use the search function to find keywords of your requirements in the documentation and set everything up. When you get stuck ask again.


 
Edwin Tempah:
Hi programmers, ive been trying to figure out a way of getting the number of open positions for a specific symbol in an ea for example the number of open positions in USDCHF, does anyone have an idea i'd appreciate any idea on how to start

Calculate Positions and Pending Orders

How to start with MQL5
How to start with MQL5
  • 2020.12.19
  • www.mql5.com
This thread discusses MQL5 code examples. There will be examples of how to get data from indicators, how to program advisors...
 

I managed to get the best way of doing it in mql5, so it goes

***
The ea stores the magic number for the symbol it is attached to.
 
Edwin Tempah # :

I managed to get the best way of doing it in mql5, so it goes

***
The ea stores the magic number for the symbol it is attached to.

1. Please do not confuse two concepts: "Pending Order" and "Position"

2. Please insert the code correctly: when editing a message, press the button   Codeand paste your code into the pop-up window 

Reason: