I use this code to get the number of deals in a position. I believe you can make minor modifications to serve your purpose.
// I use this to return the number of deals in a position. //+------------------------------------------------------------------+ //| return Total Deals in current open position | //+------------------------------------------------------------------+ int PositionDeals() { uint pos_total=0; int total=0; ulong pos_id=0; pos_total=PositionsTotal(); if(pos_total > 0) { for(uint i=0;i<pos_total;i++) { if(PositionSelect(Symbol())) { pos_id=(ENUM_POSITION_PROPERTY_INTEGER)PositionGetInteger(POSITION_IDENTIFIER); HistorySelectByPosition(pos_id); total=HistoryDealsTotal(); return(total); } } } return(0); }
- www.mql5.com
I use this code to get the number of deals in a position. I believe you can make minor modifications to serve your purpose.
I meant a bit different but anyway thanks for your help and time.
I was solved the problem before.
What is wrong in this code that I am unable to get number of positions.
Anyone who knows, please help.
This is small example which might helps you to do what you want to do.
int PosTotal=PositionsTotal(); for(int i=0;i<PosTotal;i++) { string SymName=PositionGetSymbol(uint(i)); printf("Symbol %s: volume %f, profit %f", SymName, PositionGetDouble(POSITION_VOLUME), PositionGetDouble(POSITION_PROFIT)); }
Please read also help topic about function PositionGetSymbol.
This is small example which might helps you to do what you want to do.
Please read also help topic about function PositionGetSymbol.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
What is wrong in this code that I am unable to get number of positions.
Anyone who knows, please help.