Francisco Biaso:
Hi programmers, could you let me know if this code prevents opening more than one position simultaneously?
It should work. Have you tried it in the strategy tester?
It is working fine on the tester but I have had some reports of more than one open order simultaneously.
Thank you for share this link!
Try this.
#define ALL_SYMBOLS "All Symbols" #define ALL_MAGICS WRONG_VALUE uint positionCount(string symbol=ALL_SYMBOLS, int magic=ALL_MAGICS) { if (symbol == NULL) symbol = _Symbol; uint count = 0; for (int i=PositionsTotal()-1; i>=0; --i) { string position_symbol = PositionGetSymbol(i); if (position_symbol == "") continue; long position_magic = PositionGetInteger(POSITION_MAGIC); if ((symbol == ALL_SYMBOLS || position_symbol == symbol) && (magic == ALL_MAGICS || magic == position_magic) ){ count++; } } return count; }
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
Hi programmers, could you let me know if this code prevents opening more than one position simultaneously?