SnapShotI_v2
Download scriptThis script is designed as an automated documentation and monitoring tool for traders who need to keep a visual record of their price action. Its primary purpose is to automatically capture "snapshots" (images) of the trading chart at specific intervals, allowing you to review market movements historically without having to manually take screenshots throughout the day.
How the Logic Works
1. Automated Timing and Frequency The script calculates when to take a picture based on two main settings: how many images you want per candle (bar) and a slight delay after a new candle appears. By defining these parameters, the tool ensures that your screenshots are captured consistently—whether you want a snapshot every time the price moves significantly or at regular intervals during a trading session.
2. Smart Tracking of New Data To prevent the script from taking hundreds of photos per second, it includes "memory." It identifies when a new candle has started on your chart. Once it detects a new period, it resets its internal timer to ensure the next snapshot happens only after the specific delay you have requested. This ensures the captures are spaced out logically rather than all happening at once.
3. Sequential Image Organization The script handles the heavy lifting of file management. Every time it takes a snapshot, it automatically generates a unique filename. These filenames are organized by:
- The name of the currency pair (Symbol)
- The timeframe being viewed (Period)
- The exact date and time (Year, Month, Day, Hour, Minute, and Second)
- A sequential number to ensure that multiple photos taken in the same minute do not overwrite each other.
4. Automatic File Saving Once a snapshot is triggered, the script saves the image as a high-quality GIF file in a dedicated folder on your computer. You don't need to manually name files or navigate folders; the tool creates an organized chronological archive of your trading environment automatically.
Key Benefits for the User
- Hands-Free Documentation: Ideal for traders who want to "replay" their day later to see exactly what the chart looked like at specific moments.
- Organized Archives: Because the files are named with timestamps, you can easily find a specific moment in your trading history.
- Customizable Density: You can choose to have high-frequency captures for volatile sessions or low-frequency captures for longer-term swing trading.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| 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