returning multiple values from a method

 

Hello,

I need to return multiple values from a method.

Actually I'm already using a struct but it doesn't work properly (sometimes it returns true value but sometimes returns EMPTY_VALUE).

struct orderValue
  {
   double            price;
   double            tp;
   double            vol;
   datetime          time;

  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class OrderManagement 
  {

public:
   orderValue        OrderCount(string pSymbol,int type);
                     OrderManagement(void);
                    ~OrderManagement(void);
  };


OrderManagement::OrderManagement(void)
  {

  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
OrderManagement::~OrderManagement(void)
  {
  }


orderValue OrderManagement::OrderCount(string pSymbol,int type)
  {
   orderValue order;
   
   

   for(int i=0; i<PositionsTotal(); i++)
     {

      if(PositionGetSymbol(i)==pSymbol && (int)PositionGetInteger(POSITION_TYPE)==type)
        {
         order.tp=PositionGetDouble(POSITION_TP);
         order.price= PositionGetDouble(POSITION_PRICE_OPEN);
         order.vol=PositionGetDouble(POSITION_VOLUME);
        break;
        }
     }
   return order;
  }


// The code using class OrderManagement 


void TradeForPairCurrencies(string symbol,ENUM_TIMEFRAMES tf,int flag)
  {
  
  OrderManagement order;
   orderValue buyOrder=order.OrderCount(symbol,ORDER_TYPE_BUY);
   orderValue sellOrder=order.OrderCount(symbol,ORDER_TYPE_SELL);
.
.
.
  }




 
amin_mohammadi:

Hello,

I need to return multiple values from a method.

Actually I'm already using a struct but it doesn't work properly (sometimes it returns true value but sometimes returns EMPTY_VALUE).

And what is your problem concretely ?
 
angevoyageur:
And what is your problem concretely ?
Is this a true approach? if yes why is it working wrong?
 
amin_mohammadi:
Is this a true approach? if yes why is it working wrong?
I don't see a problem with this approach. What is working wrong ? That doesn't mean anything useful to help you, "wrong" !
Reason: