forex software

Create and Test Forex Strategies

forex software

Skip to forum content

Forex Forum

Forex Software, Forex Strategies, Expert Advisors Generator

You are not logged in. Please login or register.


Forex Forum → Help and Support → How to calculate number of buy and sells order from history

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 1

Topic: How to calculate number of buy and sells order from history

Hey,

can someone help out how i can calculate the amount of closed buy and sell positions from an ea and put in in a comment to show on chart?

So it must be a calculation for exactly the magicnumber and symbol.
i tried it with this

//+------------------------------------------------------------------+
//| Calculate history closed buy positions                                        |
//+------------------------------------------------------------------+
int CalculateCurrentOrdersbuys(int buy)
  {
   int buys=0;
//----
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number && OrderType()==OP_BUY)
        {
         buys++;
         
        }
     }
return(buys);
  }
//+------------------------------------------------------------------+
//| Calculate history closed sell positions                                            |
//+------------------------------------------------------------------+
int CalculateCurrentOrderssells(int sell)
  {
   int sells=0;
//----
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number)
        {
         if(OrderType()==OP_BUY)  sells++;
        }
     }
return(sells);
  }  

and this in ontick

 Comment(          "---------------| Buys: ",CalculateCurrentOrdersbuys(0),"\n", 
           "---------------| Sells: ",CalculateCurrentOrderssells(0));   

Posts: 1

Pages 1

You must login or register to post a reply

Forex Forum → Help and Support → How to calculate number of buy and sells order from history

Similar topics in this forum