Edit Your Comment
OrdersTotal
Mar 22, 2015 at 09:08
(已编辑 Mar 21, 2015 at 18:18)
会员从Sep 04, 2014开始
25帖子
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开始
1601帖子

forex_trader_25447
会员从Dec 21, 2010开始
127帖子
Mar 23, 2015 at 09:03
(已编辑 Mar 23, 2015 at 09:10)
会员从Dec 21, 2010开始
127帖子
@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
Apr 05, 2015 at 08:15
(已编辑 Apr 05, 2015 at 08:16)
会员从Sep 16, 2009开始
188帖子
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 ...

*商业用途和垃圾邮件将不被容忍,并可能导致账户终止。
提示:发布图片/YouTube网址会自动嵌入到您的帖子中!
提示:键入@符号,自动完成参与此讨论的用户名。