Previous Next

GTrade.TradesOnSymbolDirection()

Returns the number of open positions on a specific symbol.

int  GTrade.TradesOnSymbolDirection(
   ENUM_POSITION_TYPE  direction      // Desired direction for output
   string              symbol = NULL  // Symbol
   );

Parameters

direction

[in]  The direction of the open positions to be counted. POSITION_TYPE_BUY or POSITION_TYPE_SELL

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>

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


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

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

   return(INIT_SUCCEEDED);
}

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


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


See also

GTrade.TradesOnSymbol