Test of History file

Download script
Author: Copyright � 2008, Serega Lykov
Test of History file

This script is designed to act as a diagnostic tool for traders who want to verify how the trading platform retrieves and interprets historical market data. Rather than executing trades or providing signals, its primary purpose is to "audit" the information provided by the software to ensure it is accurate and consistent.

Here is a breakdown of how the logic functions:

Data Monitoring Trigger The script monitors the live price feed of a specific currency pair (by default, GBP/USD) on a one-minute timeframe. It is programmed to perform its action only when a new minute begins. It keeps track of the current time to ensure that it doesn't repeat its process multiple times during the same minute, making it efficient and organized.

Historical Data Retrieval Once a new minute is detected, the script "looks back" at the five most recent completed candles (one-minute bars). For each of these five candles, it pulls the following specific pieces of information:

  • The price at which the candle opened.
  • The highest price reached during that minute.
  • The lowest price reached during that minute.
  • The price at which the candle closed.
  • The trading volume for that period.

Information Logging As it collects this data, the script generates a detailed report in the platform's log. It prints a clear header with the current time, followed by a list showing the exact data points for each of the five previous candles.

Practical Use Case For a non-technical user, this tool serves as a "truth check." It allows you to see exactly what data the platform is feeding into your charts and indicators. By reviewing these logs, you can confirm that the history files are loading correctly and that the price fluctuations recorded by the system match your expectations before you rely on more complex trading strategies.

Price Data Components
Series array that contains open prices of each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains close prices for each barSeries array that contains tick volumes of each bar
16 Views
0 Downloads
0 Favorites
Test of History file
//+------------------------------------------------------------------+
//|                                         Test of History file.mq4 |
//|                                   Copyright © 2008, Serega Lykov |
//|                                       http://mtexperts.narod.ru/ |
//+------------------------------------------------------------------+

#property copyright "Copyright © 2008, Serega Lykov"
#property link      "http://mtexperts.narod.ru/"

extern string   symbol = "GBPUSD";
static datetime bartime;

//+------------------------------------------------------------------+
//| Iteration function                                               |
//+------------------------------------------------------------------+
int start()
  {
   datetime time = iTime(symbol,PERIOD_M1,0);
   if(bartime == time) return(0);
   bartime = time;
   Print("--------------------------------------- ",TimeToStr(bartime), " ---------------------------------------");
   for(int i=0; i<5; i++)
     {
      double open  = NormalizeDouble(iOpen(symbol,PERIOD_M1,i),Digits);
      double high  = NormalizeDouble(iHigh(symbol,PERIOD_M1,i),Digits);
      double low   = NormalizeDouble(iLow(symbol,PERIOD_M1,i),Digits);
      double close = NormalizeDouble(iClose(symbol,PERIOD_M1,i),Digits);
      int volume = iVolume(symbol,PERIOD_M1,i);
      time = iTime(symbol,PERIOD_M1,i);
      Print("shift = ",i," : Time = ",TimeToStr(time),", Open = ",open,", High = ",high,", Low = ",low,", Close = ",close,", Volume = ",volume);
     }
   return(0);
  }

//+------------------------------------------------------------------+

Comments