Edit Your Comment
OrdersTotal
Sep 04, 2014 zamanından beri üye
25 iletiler
Mar 22, 2015 at 09:08
(Mar 21, 2015 at 18:18 düzenlendi)
Sep 04, 2014 zamanından beri üye
25 iletiler
Hello,
I add this in my EA witch determinate if there is open positions. I would like it to count only for the pair of the current chart.
Someone could help me?
total=OrdersTotal();
if(total<1) //continue
Thank you!
I add this in my EA witch determinate if there is open positions. I would like it to count only for the pair of the current chart.
Someone could help me?
total=OrdersTotal();
if(total<1) //continue
Thank you!
luclevesque17@
Nov 21, 2011 zamanından beri üye
1601 iletiler
Mar 22, 2015 at 16:32
Nov 21, 2011 zamanından beri üye
1601 iletiler
if( OrderSymbol() == Symbol() && OrderMagicNumber() == YourMagicNum && (OrderType() == OP_BUY || OrderType() == OP_SELL) )
So it would count only for the specific requirement: Pair/EA/(Long or short)
So it would count only for the specific requirement: Pair/EA/(Long or short)

forex_trader_25447
Dec 21, 2010 zamanından beri üye
127 iletiler
Mar 23, 2015 at 09:03
(Mar 23, 2015 at 09:10 düzenlendi)
Dec 21, 2010 zamanından beri üye
127 iletiler
@CrazyTrader
As CrazyTrader wrote, will work on test-mode (or 1-chart), but not on more than 1 chart.
It must be in a loop , to read all orders (all pairs), and select only current pair :
int Index=OrdersTotal();
while (Index>0)
{ Index=Index-1;
OrderSelect(Index, SELECT_BY_POS, MODE_TRADES);
if( OrderSymbol() == Symbol() &&
OrderMagicNumber() == YourMagicNum &&
(OrderType() == OP_BUY || OrderType() == OP_SELL) // Pending orders NOT counted
) break; // here find 1 order and exit
}
// here continue
As CrazyTrader wrote, will work on test-mode (or 1-chart), but not on more than 1 chart.
It must be in a loop , to read all orders (all pairs), and select only current pair :
int Index=OrdersTotal();
while (Index>0)
{ Index=Index-1;
OrderSelect(Index, SELECT_BY_POS, MODE_TRADES);
if( OrderSymbol() == Symbol() &&
OrderMagicNumber() == YourMagicNum &&
(OrderType() == OP_BUY || OrderType() == OP_SELL) // Pending orders NOT counted
) break; // here find 1 order and exit
}
// here continue
Sep 04, 2014 zamanından beri üye
25 iletiler
Mar 23, 2015 at 09:54
Sep 04, 2014 zamanından beri üye
25 iletiler
Thanks a lot! Crazy trader, Yvan
I will try this
I will try this
luclevesque17@
Sep 16, 2009 zamanından beri üye
188 iletiler
Apr 05, 2015 at 08:15
(Apr 05, 2015 at 08:16 düzenlendi)
Sep 16, 2009 zamanından beri üye
188 iletiler
This is a stand alone function ... I use it heavily in my codes ... it will make things easier with functions ...
int CountTrades() {
int cnt = 0;
for (int i = OrdersTotal() - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) cnt++;
}
return (cnt);
}
int CountTrades() {
int cnt = 0;
for (int i = OrdersTotal() - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) cnt++;
}
return (cnt);
}
... oshaban ... skype: oshaban27 ...

*Ticari kullanım ve istenmeyen e-postalara müsamaha gösterilmez ve hesabın feshedilmesine neden olabilir.
İpucu: Bir resim/youtube urlsi yayınlamak, onu otomatik olarak gönderinize gömer!
İpucu: Bu tartışmaya katılan bir kullanıcı adını otomatik olarak tamamlamak için @ işaretini yazın.