Author: Copyright � 2006, MQLService
SnapShotI1

This tool is designed to automate the process of capturing visual evidence from your trading charts. It essentially acts as an automated camera that takes "snapshots" of the current market conditions at specific, customizable intervals.

Core Functionality

The primary purpose of this script is to save images of your trading screen automatically. Instead of you having to manually take screenshots every time a new price bar forms or a specific time passes, the script handles this in the background. It saves these images as GIF files, naming them with specific details like the currency pair, the timeframe, and the exact date and time they were captured, ensuring your records are organized and easy to find.

How the Logic Works

The script operates based on three main settings that determine how it behaves:

  • Timing and Frequency: You can define how many snapshots you want to capture per bar (e.g., every time a new candle appears) or set a delay to wait for a few ticks of price movement before capturing. This allows for precise control over whether you want a constant stream of images or just one high-level overview at key moments.
  • Smart Interval Calculation: The script is intelligent enough to calculate the time between shots based on your current chart timeframe. It ensures that the snapshots are distributed evenly throughout the session, maintaining a consistent pace regardless of how fast or slow the market is moving.
  • Visual Feedback: To let you know the tool is working correctly, the script can display a small status label in the corner of your chart. This label confirms that the tool is active and displays your current settings, then briefly hides during the actual capture process to ensure the resulting image is clean and unobstructed.

Summary of Workflow

  1. Monitoring: The script constantly watches the live market price and the passage of time.
  2. Triggering: Once the pre-defined time or tick requirement is met, it triggers a "capture" command.
  3. Execution: It automatically hides its own status labels (to keep the image clean), saves the screenshot to your computer with a timestamped filename, and then reappears on your screen to wait for the next interval.
13 Views
0 Downloads
0 Favorites
SnapShotI1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                    SnapShotI.mq4 |
//|                                     Copyright © 2006, MQLService |
//|                                        http://www.mqlservice.com |
//| $Id: //depot/mt4files/experts/indicators/SnapShotI.mq4#6 $
//+------------------------------------------------------------------+
#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
extern bool ShowLabel   = true; // Displays text in down left corner

#define LABEL "SnapShotILabel"

int init()
{
  ShowLabel();
  return(0);
}

int deinit()
{
  HideLabel();
  return(0);
}

void ShowLabel()
{
  if(!ShowLabel) return;
  if(!ObjectCreate(LABEL, OBJ_LABEL, 0, 0, 0))
    Print("Error: can't create label object! ", ErrorDescription(GetLastError()));
  ObjectSet(LABEL, OBJPROP_CORNER, 2);
  ObjectSet(LABEL, OBJPROP_XDISTANCE, 4);
  ObjectSet(LABEL, OBJPROP_YDISTANCE, 2);
  ObjectSetText(LABEL, "SnapShotI is active ("+DelayTicks+","+ShotsPerBar+")", 8, "Arial", Yellow);
}

void HideLabel()
{
  if(!ShowLabel) return;
  if(!ObjectDelete(LABEL))
    Print("Error deleting label: ", ErrorDescription(GetLastError()));
}

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";
  HideLabel();
  if(!ScreenShot(fn,640,480)) Print("ScreenShot error: ", ErrorDescription(GetLastError()));
  ShowLabel();
}

//+---- Programmed by Michal Rutka -----------------------------------------+

Comments