SnapShotI_v3
Download scriptThis tool is designed to automatically capture images of your trading charts at specific intervals. It serves as an automated "camera" that preserves visual data from the market without requiring manual intervention.
Core Functionality
The script monitors the price action and time progression on your platform. Its primary goal is to take "snapshots" (GIF images) of your current chart and save them to your computer. You can customize how frequently these captures occur and how many images are taken during a single timeframe bar.
How the Logic Works
1. Timing and Frequency Control The script determines when to take a photo based on two main factors:
- Time Intervals: It calculates how much time should pass between each snapshot based on your current chart period (e.g., M15, H1, etc.) and your desired "Shots Per Bar" setting.
- New Bar Detection: It identifies when a new candle (bar) appears on the chart. When a new bar starts, it can trigger an initial capture or reset its internal countdown.
2. Sequential Capture System To ensure the snapshots are organized and not overwritten, the script performs several behind-the-scenes tasks:
- Unique File Naming: Every time a snapshot is taken, the script generates a unique filename. It automatically includes the asset name (e.g., EURUSD), the current timeframe, the date, the exact hour/minute/second of capture, and a sequential number. This ensures your gallery stays organized in chronological order.
- Automatic Counting: It keeps track of how many shots have been taken so that files are saved sequentially (Shot1, Shot2, etc.).
3. Delay Mechanism The script includes a "Delay" feature. This allows you to specify a small buffer of ticks to wait after a new bar appears before taking the first image. This is useful for ensuring the chart has settled slightly before the capture occurs.
4. File Generation When the internal timer reaches the designated moment, the script executes the save command. It captures the chart area in a standard resolution and saves it directly to a folder organized by the asset and timeframe, making it easy for traders to review historical price movements or "proof" of trades later.
//+------------------------------------------------------------------+
//| SnapShotI.mq4 |
//| Copyright © 2006, MQLService |
//| http://www.mqlservice.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MQLService"
#property link "http://www.mqlservice.com"
#include <stdlib.mqh>
#property indicator_chart_window
extern int DelayTicks = 1; // Delay so many ticks after new bar
extern int ShotsPerBar = 1; // How many screen shots per bar
int start(){
static datetime last_bar;
static int DoShot = -1;
static int old_phase = 3000000;
if(ShotsPerBar > 0)
int shot_interval = MathRound((60*Period())/ShotsPerBar);
else
shot_interval = 60*Period();
int phase = MathFloor((CurTime()-Time[0])/shot_interval);
if(Time[0] != last_bar){
last_bar = Time[0];
DoShot = DelayTicks;
}else if(phase > old_phase)
MakeScreenShot("i");
old_phase = phase;
if(DoShot == 0) MakeScreenShot();
if(DoShot >= 0) DoShot -= 1;
return(0);
}
string al0(int number, int digits){
// add leading zeros that the resulting string has 'digits' length.
string result;
result = DoubleToStr(number, 0);
while(StringLen(result)<digits) result = "0"+result;
return(result);
}
void MakeScreenShot(string sx=""){
static int no=0;
no++;
string fn = "SnapShot"+Symbol()+Period()+"\\"+Year()+"-"+al0(Month(),2)+"-"+al0(Day(),2)+" "+
al0(Hour(),2)+"_"+al0(Minute(),2)+"_"+al0(Seconds(),2)+" "+no+sx+".gif";
if(!ScreenShot(fn,640,480)) Print("ScreenShot error: ", ErrorDescription(GetLastError()));
}
//+---- Programmed by Michal Rutka -----------------------------------------+
Comments