ea methods for symbol wise

8 June 2017, 06:59
jatinpruthvi
0
27

double calculateProfit()
{
/*
double profit = 0;
for (int i = 0; i < symbol_size; i++) {
/*
if(m_Position.Select(EA_Symbols_Array[i]) && m_Position.Magic() == EA_Magic){
profit = profit + m_position.Profit();
}
*/
/*
if (m_Position.SelectByMagic(EA_Symbols_Array[i], EA_Magic)) {
profit = profit + m_Position.Profit();
}
}
return profit;
*/
return AccountInfoDouble(ACCOUNT_PROFIT);
}

void closeAllOrder()
{
CTrade trade;
for (int i = PositionsTotal() - 1; i >= 0; i--)
{
{
if (!trade.PositionClose(PositionGetSymbol(i)))
{
Print(PositionGetSymbol(i), "PositionClose() method failed. Return code=", trade.ResultRetcode(),". Code description: ", trade.ResultRetcodeDescription());//--- failure message
}
}
}
/*
for (int i = 0; i < symbol_size; i++) {
if (m_Position.SelectByMagic(EA_Symbols_Array[i], EA_Magic)) {
CTrade* m_Trade = new CTrade;
while (!m_Trade.PositionClose(EA_Symbols_Array[i], 1000))
;
}
}
*/
/*
  if(m_Position.Select(EA_Symbols_Array[i]) && m_Position.Magic() == EA_Magic){
  while(!m_Trade.PositionClose(EA_Symbols_Array[i],1000));
  }
  */
/*
if(m_Position.SelectByMagic(EA_Symbols_Array[i],EA_Magic)){
while(!m_Position.PositionClose(EA_Symbols_Array[i],1000));

}*/
/*
   int PosTotal=OrdersTotal();
   for(int i=PosTotal-1; i>=0; i--){

   for(int j = 0 ; j< symbol_size ; j++){

   if(PositionGetSymbol(i)==EA_Symbols_Array[j]){
   if(EA_Magic==PositionGetInteger(POSITION_MAGIC))
   {
   if(PositionGetInteger(POSITION_TYPE)>1){
   ulong tkt=OrderGetTicket(i);
   CTrade *trade=new CTrade;
   trade.OrderDelete(tkt);
   }
   }
   }
   }
   }

   */
}

int countTotalOpenOrder()
{
/*
int ordOpened = 0;
for (int i = 0; i < symbol_size; i++) {
if (m_Position.Select(EA_Symbols_Array[i]) && m_Position.Magic() == EA_Magic) {
ordOpened++;
}
}
return ordOpened;
*/
int total=PositionsTotal();
   int count=0;
   for (int cnt=0; cnt<=total-1; cnt++) 
      {
         if(PositionSelect(Symbol()) )
            {
               if(PositionGetInteger(POSITION_MAGIC)==EA_Magic)
                  {
                     count++; 
                  }
            }
      }

    return(count);
}
Share it with friends: