loop through open orders . . . OrderSelect() then if (OrderSymbol() == "your pair")
RaptorUK:
loop through open orders . . . OrderSelect() then if (OrderSymbol() == "your pair")
loop through open orders . . . OrderSelect() then if (OrderSymbol() == "your pair")
yea that is what i have. But that does not work if there is an open trade on DIFFERENT pair.
if (OrderSymbol()!=Symbol()) return(true); this works if i have trades open on one piar only. But if i have trades open on any different pairs the this will ALWAYS RETURN TRUE as it cycles through the loop.
What i woul;d really need is this >> if (Symbol()!= OrderSymbol()) selecting the symbol and then seeing iof an existing trade matched with it. But this does not work!!
I dont know..
This isn't the code that you need but you will probably see what you do need.
int CheckPosition(int magic,string sym=""){ ticket = -1; if( sym=="" ) sym=Symbol(); for( int n=OrdersTotal()-1; n>=0; n-- ){ if( !OrderSelect(n,SELECT_BY_POS,MODE_TRADES) ) continue; if( OrderSymbol() != sym ) continue; if( OrderMagicNumber() != magic ) continue; ticket = OrderTicket(); if( OrderType()==OP_BUY ) return( LONGPOSITION ); if( OrderType()==OP_SELL ) return( SHORTPOSITION ); return( PENDINGORDER ); } return( NOPOSITION ); }
for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--) if ( OrderSelect(iPos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == Magic.Number // my magic number && OrderSymbol() == chart.symbol // and my pair. ){ // found one.
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
A question here for someonw who can help.
I want to select a currency pair,
then check to see if there is an open trade on that pair or not? >>> if no trade are open on that pair xyz............
thanks.