Tuesday, June 3, 2014

MQL - Close[] array

Close[] array contains close prices for each bar of the current chart.
Close[0] contains the actual bar and its value is changing after the fluctuations chart. See the next pictures:



A very simple mql4 code to verify the precedent explanation (copy and compile in your Metaeditor):
//+------------------------------------------------------------------+
//|                                                  probe_probe.mq4 |
//|                                    Copyright 2014, Farcas Adrian |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, Farcas Adrian"
#property link      "http://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
Comment(
"   Bars ", Bars, "\n",
" Time[0] ", Time[0], "\n",
" Open[0] ", Open[0], "\n",
" High[0] ", High[0], "\n",
"  Low[0] ", Low[0], "\n", 
"Close[0] ", Close[0], "\n",
"Volume[0] ", Volume[0], "\n"
);
   //Sleep(30000); ////---- wait for 30 seconds
  }
//+------------------------------------------------------------------+