Previous Next

GBar.MiddleOpenClose()

Returns the middle between the opening and closing price of a candle.

double  GBar.MiddleOpenClose(
   int              shift,                     // Shift
   ENUM_TIMEFRAMES  timeFrame = PERIOD_CURRENT // Time frame of the value
);

Parameter

shift

[in]  The candle offset. 0 (zero) is the current unclosed candle.

timeFrame

[in]  The timeframe of the candle.

Return value

Returns the midpoint between the opening and closing prices of a candle.


Example:

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

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


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

   return(INIT_SUCCEEDED);
}

void OnDeinit (const int reason)
{
   //--- When the program exits, release the memory
   delete bar;
}


void OnTick ()
{
   //--- Print the middle of the open/close value of the last candle
   Print( bar.MiddleOpenClose(1) );
}


See also

GBar.MiddleHighLow