GTrade.CloseAllOnSymbol()
Closes all open trades on a specific symbol.
int GTrade.CloseAllOnSymbol(
string symbol = NULL
);
|
Parameter
symbol
[in] The symbol whose trades are to be closed.
Return Value
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)
{
//--- Free up memory on exit
delete trade;
}
void OnTick
()
{
//--- Get the current hour of the day
MqlDateTime dateTimeStruct;
TimeCurrent(dateTimeStruct);
int hour = dateTimeStruct.hour;
//--- Close all open trades from 10pm
if
( hour >= 22 )
{
trade.CloseAllOnSymbol();
}
}
|
See also
GTrade.Open, GTrade.CloseWithComment