Count how many of each type you have
int nBuys = 0, nSells = 0; for(int iPos = OrdersTotal()-1; iPos >= 0; iPos--) if( OrderSelect(iPos, SELECT_BY_POS) && OrderMagicNumber() == magic.number && OrderSymbol() == symbol.chart){ if(OrderType() == OP_BUY) nBuys++; if(OrderType() == OP_SELL) nSells++; } bool isFlat = nBuys == 0 && nSells == 0;
WHRoeder:
Count how many of each type you have
Count how many of each type you have
Thanks for your help - not sure what magic.number and symbol.chart would be defined as?
I had questions about the magic number when I first started as well. There's nothing magic about the magic number. I use my birthdate.
This article will explain, https://www.mql5.com/en/articles/1359
And I use the date when starting to code a new EA - 20130429
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 am trying to establish the code for Market Position if flat, short or long could anyone help me in this?
How would you workout if the Market Position is flat, short or long - what calls can be made? would it be Order....
Thanks in advance.
Peter.