Previous Next

GTrade.TradeDirection()

Returns the direction (LONG / SHORT) of the last opened and open trade.

GDirections  GTrade.TradeDirection();
   string  symbol = NULL  // Symbol
   );

Parameter

symbol

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

Return value

Returns the GDirections direction of the last opened and open trade.


Example:

//--- Include the 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();

   //--- Die Daten der Klasse initialisieren
   trade.Init();

   return(INIT_SUCCEEDED);
}

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


void OnTick ()
{
   //--- Get the profit of the last opened trade
   PrintEnumToString(trade.TradeDirection()) );
}


See also

GTrade.TradeProfit, GTrade.TradeOpenPrice, GTrade.TradeProfitWithComment