I use OrderSelect(i,SELECT_BY_POS) to select the trades with my EA. But it affects all my trades, and I want it to affect only a few, certain trades. How can I make it work only on those certain trades, any ideas?
- only 1 trade per day
- MT5 Programming/conversion
- Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes
u can use OrderMagicNumber() for example
hondaissace:
I use OrderSelect(i,SELECT_BY_POS) to select the trades with my EA. But it affects all my trades, and I want it to affect only a few, certain trades. How can I make it work only on those certain trades, any ideas?
Select your trades using OrderSymbol() . . . . if your EA is on multiple timeframes of the same symbol then you will need to use a Magic Number
I use OrderSelect(i,SELECT_BY_POS) to select the trades with my EA. But it affects all my trades, and I want it to affect only a few, certain trades. How can I make it work only on those certain trades, any ideas?
bool MySelect(int iWhat, int eSelect, int ePool=MODE_TRADES){ if (!OrderSelect(iWhat, eSelect, ePool) ) return (false); if (OrderMagicNumber() != magic.number ) return (false); if (OrderSymbol() != analyze.pair ) return (false); if (ePool != MODE_HISTORY ) return (true); return(OrderType() <= OP_SELL); // Avoid cr/bal forum.mql4.com/32363#325360 // https://forum.mql4.com/30708 // Never select canceled orders. } // for(int iPos = OrdersTotal()-1; iPos >= 0; iPos--) if (MySelect(iPos, SELECT_BY_POS)){ :
WHRoeder:
Thanks for the reply, can you elaborate what "return(OrderType() <= OP_SELL);" is for? Why the "<" sign? Also there are supposed to be else between those ifs? Thanks for replying.
- can you elaborate what "return(OrderType() <= OP_SELL);" is forwhat part of
Avoid cr/bal
andNever select canceled orders.
was unclear? Canceled means deleted Pending orders. - also there are supposed to be else between those ifs?Why would there be any else's? If you return your gone. An IF() A else B; means you do A or B, AND THEN what ever follows. IF(){ A; return;} else B; means you're going to do A and return, or B AND whatever follows, which is the same as IF(){ A; return; } B. Simplify your code. Never use an else after a return, break, or continue. Never use IF(){A} else{B return } use IF(!..){B return } A
WHRoeder:
- can you elaborate what "return(OrderType() <= OP_SELL);" is forwhat part of
andwas unclear? Canceled means deleted Pending orders. - also there are supposed to be else between those ifs?Why would there be any else's? If you return your gone. An IF() A else B; means you do A or B, AND THEN what ever follows. IF(){ A; return;} else B; means you're going to do A and return, or B AND whatever follows, which is the same as IF(){ A; return; } B. Simplify your code. Never use an else after a return, break, or continue. Never use IF(){A} else{B return } use IF(!..){B return } A
cr/bal?
WHRoeder did post a URL linking to another post that contained:
FYI, although not officially documented, these are the OrderType() of balance/credit statements when they are selected:
- 'Balance' statement: OrderType()==6
- 'Credit' statement: OrderType()==7
OrderType() <= OP_SELL
helps weed 'em out
And in any case, answer to the query for this post is at
for(int iPos = OrdersTotal()-1; iPos >= 0; iPos--) if (MySelect(iPos, SELECT_BY_POS))
OK I get it thanks to all of you man
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