Hello,
Any ideas on how to code this?.
Lets say there is already a open BUY position with Magicnumber4. I do not want to open any additional BUY positions(i.e reject pending orders) if the account already has an open buy position with magicnumber4.
Thanks,Padhu
- Check magicnumber of open position
- How to show order type (Sell/Buy) on chart?
- How to check magic numbers of open positions
CC
Seems to be what you're after :)
Returns the number of open orders for a pair/magic number/order type
int OpenTradesForMagicNumberByType(string SymbolToCheck, int MagicNumberToCheck, int iOrderType) { int icnt, itotal, retval; retval=0; itotal=OrdersTotal(); for(icnt=0;icnt<itotal;icnt++) { OrderSelect(icnt, SELECT_BY_POS, MODE_TRADES); // check for opened position, symbol & MagicNumber if(OrderType()<=iOrderType && OrderSymbol()==SymbolToCheck && OrderMagicNumber()==MagicNumberToCheck) { retval++; //Print("Orders opened : ",retval); } } return(retval); }
Good luck
-BB-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