//+------------------------------------------------------------------+ //| IndCreateOffline.mq4 | //| Copyright 2016, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2016, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property description "The indicator creates an offline chart" #property strict #property indicator_chart_window //+------------------------------------------------------------------+ //| Enumerations of periods offline chart | //+------------------------------------------------------------------+ enum ENUM_OFF_TIMEFRAMES { M2=2, // period M2 M3=3, // period M3 M4=4, // period M4 M6=6, // period M6 }; //--- input parameter input ENUM_OFF_TIMEFRAMES ExtOffPeriod=M6; //--- bool crash=false; // false -> error in the code int HandleHistory=-1; // handle for the opened "*.hst" file datetime time0; // ulong last_fpos=0; // long last_volume=0; // int periodseconds; // int i_period; // MqlRates rate; // long ChartOffID=-1; // ID of the offline chart //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { if(!IsOffline(ChartID()) && Period()!=PERIOD_M1) { Print("The period on the online chart must be \"M1\"!"); crash=true; } //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ //| The function checks offline mode of the chart | //+------------------------------------------------------------------+ bool IsOffline(const long chart_ID=0) { bool offline=ChartGetInteger(chart_ID,CHART_IS_OFFLINE); return(offline); } //+------------------------------------------------------------------+