Previous Next

GBar.CandleBodySpread()

Returns the size of the body of a candle.

double  GBar.CandleBodySpread(
   int              shift,                     // Shift
   ENUM_TIMEFRAMES  timeFrame = PERIOD_CURRENT // Timeframe of the value
);

Parameter

shift

[in]  The shift of the candle. 0 (zero) is the current uncompleted candle.

timeFrame

[in]  The timeframe of the candle.

Return Value

Returns the range from the opening price to the closing price of a candle.


Example:

//--- Include Glib class
#include <Glib.mqh>

//--- Create a pointer to an empty class object
GBar *bar;


int OnInit ()
{
   //--- Assign a class to the empty class object
   bar = gBar();

   return(INIT_SUCCEEDED);
}

void OnDeinit (const int reason)
{
   //--- free memory on closing
   delete bar;
}


void OnTick ()
{
   //--- Print the spread between Open/Close of the last candle
   Print( bar.CandleBodySpread(1) );
}


See also

GBar.CandleFullSpread