SnapShotI_v1
Download scriptThis script is designed to serve as an automated visual logging tool for your trading platform. Its primary purpose is to capture the current state of your price charts at precise intervals, creating a historical record of market movements and your workspace layout.
How the Logic Works
The script operates on a continuous "monitoring" cycle. Instead of running constantly or requiring manual input, it watches the flow of time on your trading platform. Here is the step-by-step breakdown of its behavior:
1. Real-Time Monitoring The script keeps track of the current candle (the timeframe bar) on your chart. It constantly checks if a new candle has started. If the time of the current candle matches the time it last recorded, the script stays idle to save system resources.
2. Trigger Mechanism The moment a new candle appears on your screen, the script recognizes this as a "snapshot event." It triggers a specific action once per candle—ensuring that you get a fresh image exactly at the start of each new time period (e.g., every hour, every 15 minutes, or every day, depending on your chart setting).
3. Automatic File Organization When a snapshot is taken, the script automatically generates a unique filename based on your specific trading environment. It gathers the following data points to name the file:
- The specific Currency Pair (Symbol) you are viewing.
- The Timeframe (Period) of the chart.
- The exact Date and Time (Year, Month, Day, Hour, Minute, and Second).
- A sequential number to ensure that if multiple shots are taken, they do not overwrite each other.
4. Image Capture Finally, the script captures a high-resolution image of your current chart window and saves it as a .gif file on your computer. By organizing these files into folders based on the symbol and period, it creates an organized archive that allows you to look back at exactly what the market looked like at any specific moment in time.
Summary for the User
Think of this script as an "automatic camera" for your trading desk. Every time a new candle opens, it clicks a photo and files it away into a folder labeled with the correct date and time. This allows you to build a visual diary of your trades without having to manually take screenshots yourself.
//+------------------------------------------------------------------+
//| SnapShotI.mq4 |
//| Copyright © 2006, MichalRutka |
//| http://www.mqlservice.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MichalRutka"
#property link "http://www.mqlservice.com"
#property indicator_chart_window
int start(){
static datetime last_bar;
if(Time[0] != last_bar){
last_bar = Time[0];
MakeScreenShot();
}
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(){
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+".gif";
if(!ScreenShot(fn,640,480)) Print("ScreenShot error: ", GetLastError());
}
//+----Coded by Michal Rutka-----------------------------------------+
Comments