SnapShotEA
Download scriptThis automated tool is designed as a visual monitoring utility for traders who need to audit their trading strategies or verify the integrity of their technical indicators. Its primary purpose is to provide a systematic, chronological record of what your trading screen looks like at specific moments in time.
Core Functionality
The script operates by automatically capturing an image of your current trading chart every time a new price bar (candle) opens. Rather than taking constant screenshots, it waits for the transition between bars to ensure that each captured image represents a fresh period of market activity.
Key Features and Logic
- Automatic Triggering: The system monitors the live feed of the market. Every time the time moves forward to a new bar, the tool triggers a capture. This ensures a consistent history is built without requiring manual intervention from the user.
- Dynamic File Organization: To keep your records organized, the script automatically generates unique filenames based on the specific details of the chart you are viewing. The filename includes the currency pair (Symbol) and the timeframe (Period).
- Time-Stamped Records: Each captured image is labeled with a precise timestamp, including the year, month, day, hour, minute, and second. This allows users to easily navigate through a history of market movements to see exactly how their charts appeared at any given moment.
- Sequential Numbering: In instances where multiple snapshots might occur rapidly, the script adds a sequential number to the filename to prevent data from being overwritten, ensuring every capture is saved uniquely.
- Storage Location: The resulting images are automatically saved into a specific folder within your MetaTrader installation, making it easy for you to browse your history in a standard image viewer.
Practical Use Case
This tool is specifically intended for "back-testing" and quality assurance. It is highly useful for traders who suspect that certain indicators might be "repainting"—a situation where an indicator changes its past values based on new data. By reviewing these snapshots, you can visually confirm if the history of the chart remains consistent or if it shifts as new information arrives.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| SnapShotEA.mq4 |
//| Michal Rutka |
//| www.mqlservice.com |
//| |
//| Creates a screen shot at beginning of every new bar. GIFs are |
//| placed in experts/files/ subdirectory of your MetaTrader |
//| instalation. Use this utility when you want manually test your |
//| strategy, to spot if you have any indicators that change its |
//| past values. |
//+------------------------------------------------------------------+
#property copyright "Michal Rutka"
#property link "www.mqlservice.com"
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());
}
Comments