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 ...

*상업적 사용 및 스팸은 허용되지 않으며 계정이 해지될 수 있습니다.
팁: 이미지/유튜브 URL을 게시하면 게시물에 자동으로 삽입됩니다!
팁: @기호를 입력하여 이 토론에 참여하는 사용자 이름을 자동으로 완성합니다.