Previous Next


Closes all open trades on a specific symbol.

int  GTrade.CloseAllOnSymbol(
   string  symbol = NULL  // Symbol



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

Return Value

Returns the number of closed trades.


//--- 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


void OnDeinit (const int reason)
   //--- Free up memory on exit
   delete trade;

void OnTick ()
   //--- Get the current hour of the day
   MqlDateTime dateTimeStruct;
   int hour = dateTimeStruct.hour;

   //--- Close all open trades from 10pm
   if ( hour >= 22 )

See also

GTrade.Open, GTrade.CloseWithComment