-
Don't post pictures of code, they are too hard to read.
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
Messages Editor - If there are n positions, their indexes are [0…n-1]. Not n+1!
int Initial_Volume() { int IV; int total = PositionsTotal(); for(int i = total-1; i >= 0; i--) { if(PositionGetTicket(i) <= 0) continue; if(PositionGetInteger(POSITION_MAGIC) != MagicNumber || PositionGetString(POSITION_SYMBOL) != Symbol()) continue; double IVA[]; int PV = PositionGetDouble(POSITION_VOLUME); ArrayFill(IVA,0,123,PV); IV = ArrayMaximum(IVA,0,123); } return IV; }
-
Don't post pictures of code, they are too hard to read.
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
Messages Editor - If there are n positions, their indexes are [0…n-1]. Not n+1!
thanks for the reply, i had it at -1 and it still did not work. ill give it a go with 0
I think you probably want it this way.
thanks for the reply/help
the code you posted runs without errors, but im looking for a way to get the max volume of the current trade ticket.
this code returns something different
so do we have to make a new array each trade?
There was an error in my program and I removed it.
right as i posted my last comment i noticed it disappeared.. i thought i did something wrong when i was replying lol
How about this one?
int Initial_Volume() { int IV; int total = PositionsTotal(); double IVA[]; ArrayResize(IVA, total); for(int i = 0; i < total; i++) { if(PositionGetTicket(i) <= 0) continue; if(PositionGetInteger(POSITION_MAGIC) != MagicNumber || PositionGetString(POSITION_SYMBOL) != Symbol()) continue; IVA[i] = PositionGetDouble(POSITION_VOLUME); } IV = (int)IVA[ArrayMaximum(IVA)]; return (IV); }
How about this one?
it wont compile 3 errors and 1 warning

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi I'm trying to get the initial volume of a ticket, so I can then use that value in my EA.