//+------------------------------------------------------------------+ //| MinMax2years.mq5 | //| Copyright 2013, Alain Verleyen | //| https://login.mql5.com/en/users/angevoyageur | //+------------------------------------------------------------------+ #property copyright "Copyright 2013, Alain Verleyen" #property link "https://login.mql5.com/en/users/angevoyageur" #property version "1.00" #property indicator_chart_window #property indicator_plots 0 //--- input parameters input datetime MinMaxFrom=0; // 0 = 2 years, otherwise enter your past date //--- globals datetime fromDate; double pastmin=DBL_MAX; double pastmax=-DBL_MIN; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- input parameter checking if(MinMaxFrom==0) fromDate=TimeCurrent()-2*365*24*3600; // Approximately 2 years, can be modified for more accuracy else if(MinMaxFrom=fromDate) { if(high[i]>pastmax) pastmax=high[i]; if(low[i]