mt5 to remember zoom per timeframe?

 
is there any setting or utility to make mt5 remember chart zoom of each timeframe?
 
Payman:
is there any setting or utility to make mt5 remember chart zoom of each timeframe?

Interesting .
There is now 

Place it in Indicators Folder ,you can also add this to your template .
You can specify the folder where data is kept too ,but then you have to compile it again.

//+------------------------------------------------------------------+
//|                                                    Zoomemory.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
string this_tf="X";
string folder="ZoomData";
char this_zoom=0;
int OnInit()
  {
//--- indicator buffers mapping
  this_tf=TfToString(_Period);
  LoadZoom();
  ChartSetString(ChartID(),CHART_COMMENT,"Chart ZoomMemory Active");
//---
   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);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
  if(id==CHARTEVENT_CHART_CHANGE)
    {
    char new_zoom=(char)ChartGetInteger(ChartID(),CHART_SCALE,0);
    if(new_zoom!=this_zoom)
      {
      SaveZoom(new_zoom);
      this_zoom=new_zoom;
      }
    }
  }
//+------------------------------------------------------------------+

void LoadZoom()
{
this_zoom=(char)ChartGetInteger(ChartID(),CHART_SCALE,0);
string location=folder+"\\"+Symbol()+"_"+this_tf+".zoom";
if(FileIsExist(location))
  {
  int fop=FileOpen(location,FILE_READ|FILE_BIN);
  if(fop!=INVALID_HANDLE)
    {
    char zl=(char)FileReadInteger(fop,CHAR_VALUE);
    this_zoom=zl;
    ChartSetInteger(ChartID(),CHART_SCALE,(long)zl);
    FileClose(fop);
    }
  }
}
void SaveZoom(char new_zoom)
{
string location=folder+"\\"+Symbol()+"_"+this_tf+".zoom";
if(FileIsExist(location)) FileDelete(location);
int fop=FileOpen(location,FILE_WRITE|FILE_BIN);
if(fop!=INVALID_HANDLE)
  {
  FileWriteInteger(fop,new_zoom,CHAR_VALUE);
  FileClose(fop);
  }
}
string TfToString(ENUM_TIMEFRAMES tf)
{
if(tf==PERIOD_M1) return("M1");
if(tf==PERIOD_M2) return("M2");
if(tf==PERIOD_M3) return("M3");
if(tf==PERIOD_M4) return("M4");
if(tf==PERIOD_M5) return("M5");
if(tf==PERIOD_M6) return("M6");
if(tf==PERIOD_M10) return("M10");
if(tf==PERIOD_M12) return("M12");
if(tf==PERIOD_M15) return("M15");
if(tf==PERIOD_M20) return("M20");
if(tf==PERIOD_M30) return("M30");
if(tf==PERIOD_H1) return("H1");
if(tf==PERIOD_H2) return("H2");
if(tf==PERIOD_H3) return("H3");
if(tf==PERIOD_H4) return("H4");
if(tf==PERIOD_H6) return("H6");
if(tf==PERIOD_H8) return("H8");
if(tf==PERIOD_H12) return("H12");
if(tf==PERIOD_D1) return("D1");
if(tf==PERIOD_W1) return("W1");
return("X");
}
Files:
Zoomemory.mq5  4 kb
Zoomemory.ex5  21 kb
 
Payman:
is there any setting or utility to make mt5 remember chart zoom of each timeframe?

load on OnInit, x is variable

ChartSetInteger(0,CHART_SCALE,x);
 
Lorentzos Roussos:

Interesting .
There is now 

Place it in Indicators Folder ,you can also add this to your template .
You can specify the folder where data is kept too ,but then you have to compile it again.

thanks so much, it works!

Mohamad Zulhairi Baba:

load on OnInit, x is variable

thanks, i have to add it to other indicators on my chart or should i make a new indi?!
Reason: