Hi!
You can add checking
PositionGetString(POSITION_SYMBOL) == _Symbol
Hi, i tried this but It doesn't work.
for(int i = PositionsTotal() - 1 ; i >= 0 ; i--) { PositionGetTicket(i); if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY ) { if(PositionGetString(POSITION_SYMBOL) == _Symbol) { buy_count++; } } if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL ) { if(PositionGetString(POSITION_SYMBOL) == _Symbol) { sell_count++; } } }
Anton Ohurtsov #:
You should select position by PositionSelectByTicket()
You should select position by PositionSelectByTicket()
thanks for the help but i'm sorry it's still doesn't work
if(PositionsTotal() > 0) for(int i = 0; i < PositionsTotal(); i++) { ulong ticket = PositionGetTicket(i); if(PositionSelectByTicket(ticket)) if(PositionGetInteger(POSITION_MAGIC) == InMagicnumber) if(PositionGetString(POSITION_SYMBOL) == _Symbol) if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY) { buy_count++; } if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL) { sell_count++; } }
Are your positions opened with InMagicnumber?
Okay it works !
for those who want the code :
double OpenPrice; for(int v = 0; v< total_open_positions; v++) { ulong positionticket = PositionGetTicket(v); ulong magic=PositionGetInteger(POSITION_MAGIC); if(PositionSelectByTicket(positionticket)) { if(magic ==InMagicnumber ) { OpenPrice= PositionGetDouble(POSITION_PRICE_OPEN); } } }
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
Hello,
I would like to use my EA on different symbols on the same MT5 account but I can't because in some parts of the code I used PositionsTotal, or a double openprice but they are focusing on all the symbols on the account.
I would like that this code only work on the current chart but I can't find a way to fix this, can you help me ? Thanks