Previous Next

GTrade.TradeProfitWithComment()

Returns the current profit of an open trade with a specific comment on a specific symbol.

double  GTrade.TradeProfitWithComment(
   string  comment,       // Required comment for output
   string  symbol = NULL  // Symbol
   );

Parameter

comment

[in]  The comment that the open position must contain to output the value.

symbol

[in]  The symbol from which the value should be output.

Return value

Returns the profit of the last opened trade with a certain comment.


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 ()
{
   //--- Get the profit of a specific open trade
   Print( trade.TradeProfitWithComment("Auto Trade") );
}


See also

GTrade.TradeProfit, GTrade.TradeOpenPrice, GTrade.TradeDirection