OrdersTotal

Mar 22, 2015 at 09:08
820 व्यू
4 Replies
तबसे मेंबर है Sep 04, 2014   25 पोस्टों
Mar 22, 2015 at 09:08 (एडिट हो रहा है Mar 21, 2015 at 18:18)
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!
luclevesque17@
तबसे मेंबर है Nov 21, 2011   1601 पोस्टों
Mar 22, 2015 at 16:32
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)
forex_trader_25447
तबसे मेंबर है Dec 21, 2010   127 पोस्टों
Mar 23, 2015 at 09:03 (एडिट हो रहा है Mar 23, 2015 at 09:10)
@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
तबसे मेंबर है Sep 04, 2014   25 पोस्टों
Mar 23, 2015 at 09:54
Thanks a lot! Crazy trader, Yvan
I will try this
luclevesque17@
तबसे मेंबर है Sep 16, 2009   188 पोस्टों
Apr 05, 2015 at 08:15 (एडिट हो रहा है Apr 05, 2015 at 08:16)
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);
}
... oshaban ... skype: oshaban27 ...
You must be connected to Myfxbook in order to leave a comment
*व्यवसायिक इस्तेमाल और स्पैम को ब्रदाश नहीं किया जाएगा, और इसका परिणाम खाता को बन्द करना भी हो सकता है.
टिप: किसी चित्र या यूट्यूब या URL को पोस्ट करने से वे अपने आप आपके पोस्ट में आजाएगा!
टिप: @ चिन्ह को टाइप करें उपभोगता के नाम को अपने आप करने के लिए जो इस चर्चा में भाग ले रहा है.