Please use the button to insert the code (the first time I corrected your message)
Function for calculating BUY and SELL positions:
//+------------------------------------------------------------------+ //| Calculate all positions Buy and Sell | //+------------------------------------------------------------------+ void CalculateAllPositions(int &count_buys,int &count_sells) { count_buys=0; count_sells=0; for(int i=PositionsTotal()-1; i>=0; i--) if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==InpMagic) { if(m_position.PositionType()==POSITION_TYPE_BUY) count_buys++; if(m_position.PositionType()==POSITION_TYPE_SELL) count_sells++; } //--- return; }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
This code of mine was not counting only buy positions it count also sell position but I want it to count it separately to have a value of how many buy and sell position I have.
Please help me find the problem.