Just loop through all the Orders and count the Buys and count the Sells....
For the values you can use something like this...
{
for(x=OrdersTotal();x>=0;x--)
{
OrderSelect(x,SELECT_BY_POS);
{
if(OrderType()==OP_BUY)
{
BuyProfit= BuyProfit+OrderProfit();
}
if(OrderType()==OP_SELL)
{
SellProfit= SellProfit+OrderProfit();
}
}
}
}
Just loop through all the Orders and count the Buys and count the Sells....
For the values you can use something like this...
{
for(x=OrdersTotal();x>=0;x--)
{
OrderSelect(x,SELECT_BY_POS);
{
if(OrderType()==OP_BUY)
{
BuyProfit= BuyProfit+OrderProfit();
}
if(OrderType()==OP_SELL)
{
SellProfit= SellProfit+OrderProfit();
}
}
}
}
Thanks, But the count of orders to do the separation? How many sell and buy, if orderstotal () is the sum?
Thanks, But the count of orders to do the separation? How many sell and buy, if orderstotal () is the sum?
Just Loop through and count...Your Buy++ and Sell++ with Buy ==0; and Sell==0; somewhere after you've used your count data should work..
int SellCount=0, BuyCount=0; double SellProfit=0, BuyProfit=0; for(int index = OrdersTotal() - 1; index >= 0; index--) if ( OrderSelect(index, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == MagicNumber // my magic number && OrderSymbol() == Symbol() ) { // and symbol if (OrderType()==OP_BUY) { BuyCount++; BuyProfit += OrderProfit(); } else { SellCount++; SellProfit += OrderProfit(); } }
Why not use the MODE_TRADES? Since it is open for orders?
And then when you close an open order, how to make the count and the value decrease?
Read the documentation, the default IS MODE_TRADES.
bool OrderSelect(int index, int select, int pool=MODE_TRADES)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
OrdersTotal () - How do I separate Buy and Sell orderstotal count ()?
In number of orders for each type
In values of orders of each type
Example OrdersTotal () = 6
Sell = 3
Buy = 3
Value Buy = -120.00
Value Sell = -135.00
I tried the script below but lacks a loop that I have no idea.
if (OrdersTotal()==0)
{
Sell=0;
Buy=0;
BuyValue=0;
SellValue=0;
}
for(int a=OrdersTotal() - 1; a >= 0; a--)
{
if(OrderSelect(a,SELECT_BY_POS,MODE_TRADES)==false) break;
//---- check order type
RefreshRates ();
if(OrderType()==OP_BUY)
{
Buy=Buy+1;
BuyValue=BuyValue+(MathAbs(((Bid-OrderOpenPrice())*OrderLots())*100000));
}
if(OrderType()==OP_SELL)
{
Sell=Sell+1;
SellValue=SellValue+(MathAbs(((Bid-OrderOpenPrice())*OrderLots())*100000));
}
}
Please help me in the script, I have difficulty in developing scripts.