Previous Next

GTrade.TradesOnSymbol()

Returns the number of open positions on a specific symbol.

int  GTrade.TradesOnSymbol(
   string  symbol = NULL  // Symbol
   );

Parameter

symbol

[in]  The symbol whose trades are to be counted.

Return Value

Returns the number of open trades.


Example:

//--- Include Glib classes
#include <Glib.mqh>

//--- Creation of a pointer to an empty class object
GTrade *trade;


int OnInit ()
{
   //--- Assign the class to the empty class object
   trade = gTrade();

   //--- Initialize the data of the class
   trade.Init();

   return(INIT_SUCCEEDED);
}

void OnDeinit (const int reason)
{
   //--- Release memory on exit
   delete trade;
}


void OnTick ()
{
   //--- Prints the current number of open positions
   Print( trade.TradesOnSymbol() );
}


See also

GTrade.TradesOnSymbolDirection