autosave graph every hour

 

Is there already a solution to automate these:

  1. right click
  2. save picture as
  3. active chart (as is)
  4. save into IIS image webfolder where I can open from phone's web browser
 
simili:

Is there already a solution to automate these:

  1. right click
  2. save picture as
  3. active chart (as is)
  4. save into IIS image webfolder where I can open from phone's web browser

Hi, Please specify what you mean by "save picture as". Do you need to save a screenshot of the entire screen, MT5 terminal window or just an MT5 chart?

 
Artur Zas:

Hi, Please specify what you mean by "save picture as". Do you need to save a screenshot of the entire screen, MT5 terminal window or just an MT5 chart?

on my mt4, I want to save current H1 chart with heiken ashi bar chart. Just the graf like this


 
simili:

on my mt4, I want to save current H1 chart with heiken ashi bar chart. Just the graf like this



#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.haskayayazilim.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
datetime prevtime;
int  ExtShotsCounter;
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
SaveGraph();
   
  }
//+------------------------------------------------------------------+

int SaveGraph()
{

     if(iTime(Symbol(),60,0) == prevtime)  return(0);
     prevtime = iTime(Symbol(),60,0);
     ExtShotsCounter++;
     WindowScreenShot("shots\\tester"+ExtShotsCounter+".gif",640,480);
      
return(0);
}
 
simili:

on my mt4, I want to save current H1 chart with heiken ashi bar chart. Just the graf like this


You can use an easy solution like the one I provided below, or you can build on it.

Please note that MT4 will not let you write outside of the {MT4 Data Folder} / MQL4 / Files folder so you can do a simple trick and add a symlink to your IIS images web folder inside the  {MT4 Data Folder} / MQL4 / Files. This way the files will actually be written to the IIS images web folder.

Creating symlinks is relatively easy, but if you don't know what they are and how to create them, you can look here: https://www.maketecheasier.com/create-symbolic-links-windows10/

Instead of symlinks you can also use Windows API calls via DLL imports to copy the file over, but that may be a bit of an overkill - a symlink should be sufficient.

Anyway, here is an EA you can use for the screengrab process:

//+------------------------------------------------------------------+
//|                                                     Snapshot.mq4 |
//|                                        Copyright 2018, Artur Zas |
//|                                         https://www.az-invest.eu |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, Artur Zas"
#property link      "https://www.az-invest.eu"
#property version   "1.00"
#property strict

#include <stderror.mqh> 
#include <stdlib.mqh> 

input string InpImageWebfolder   = "IIS image webfolder";   // IIS image webfolder symlink
input int    InpSaveInterval     = 3600;                    // Save new image every x seconds
input int    InpWidth            = 2048;                    // Width of image in pixels
input int    InpHeight           = 1536;                    // Height of image in pixels

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
   IsNewHour(true);
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
   if(!IsNewHour(false))
      return;

   string fileName = StringFormat("%s\\%s%d.png", InpImageWebfolder, _Symbol, _Period);
   
   if(!ChartScreenShot(0,fileName,InpWidth,InpHeight))
   {
      string err = StringFormat("Error saving screenshot of %s(%d) chart - %s",_Symbol,_Period,ErrorDescription(GetLastError()));
      Alert(err);
   }
   else
   {
      PrintFormat("Saved screenshot to %s",fileName);
   }
}
//+------------------------------------------------------------------+

bool IsNewHour(bool reset)
{
   static datetime last = 0;
   
   if(reset)
   {
      last = 0;
      return false;
   }
   
   if(last == 0)
   {
      last = TimeCurrent();
      return true;
   }

   datetime current = TimeCurrent();
   if(current - last > 3600)
   {
      last = current;
      return true;
   }

   return false;
}


How to Create Symbolic Links in Windows 10
How to Create Symbolic Links in Windows 10
  • 2017.02.12
  • www.maketecheasier.com
Symlinks or Symbolic Links is one of the lesser known, yet useful, feature in Windows. You can think of symbolic links as the shortcuts you create in Windows. However, symbolic links are much more powerful and helpful than regular shortcuts. Let’s discuss what symbolic links are and how you can easily create them in Windows 10. What Are...
Files:
Snapshot.mq4  3 kb
 

I am not sure what is wrong, i am just not getting it to work. When executed in MetaEditor the screenshot appears but not getting saved but when  i am executing CSV file data export it is getting saved.

Any help would be highly appreciated.

Thank You.

Reason: