Download MetaTrader 5
To add comments, please log in or register
Have you installed MetaTrader 5? Find out more about it!
trader88888
131
trader88888 2014.12.18 15:32 

Hello,

 

This seems to be a very odd problem but I have a line of code which takes a screenshot with a certain size.  The image file always gets created but sometimes the file size is 0 an others its the full image.  It's the same code that gets executed on the same mt4 instance so I can't figure out what would be creating the image with a file size of 0 and sometimes it working as expected.

 

Any ideas on how i can troubleshoot this or what the problem could be? 

Carl Schreiber
5945
Carl Schreiber 2014.12.18 16:04  
With out code?
trader88888
131
trader88888 2014.12.18 16:59  
gooly:
With out code?

Yes because the code is the same line being executed over and over again.  

 

Here is the line of code:

WindowScreenShot(filename,640,480);

 

The problem is not the code because I know it's the same line over and over again.  The problem is that multiple screenshots over a quick succession of them  do not work or something else, this is what im trying to figure out.

Carl Schreiber
5945
Carl Schreiber 2014.12.18 17:47  

Well I think you have given your answer yourself: too many in a short time.

You can buy a new and faster pc or at least a fast SSD harddisk - I think anything else won't help.

trader88888
131
trader88888 2014.12.19 04:42  
That was just me guessing, i don't know if this is the case.  How can i confirm that it is?
trader88888
131
trader88888 2014.12.19 05:15  
trader88888:
That was just me guessing, i don't know if this is the case.  How can i confirm that it is?
If i was to try and "slow" down the indicator by using sleep - it turns out I can't:    From the docs:  "The Sleep() function can't be called for custom indicators".  Any other ides on how this could be done so the file could be able to write?
SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.12.19 06:31  
Try using EA and let the EA take care of the screenshot. You can also use sleep() if you want or timer. Using script will not help much but you can do a lot more using EA.
honest_knave
962
honest_knave 2014.12.19 08:18  

When you want to start taking screenshots, call EventSetTimer() or EventSetMillisecondTimer().

When you want to stop taking shots, call EventKillTimer()

In OnTimer(), add you code for taking screenshots.

Example: if you set EventSetTimer(1), a screenshot will be taken every second until you kill the timer.

Carl Schreiber
5945
Carl Schreiber 2014.12.19 08:37  
trader88888:
That was just me guessing, i don't know if this is the case.  How can i confirm that it is?

You can see how long it is blocked if you place right before and after your order WindowScreenShot(..) a GetTickCount():

   //--- Remember the initial value
   uint click=GetTickCount();
   WindowScreenShot(..)
   //--- Get the spent time in milliseconds
   click=GetTickCount()-click;
   Print("Blocked: ",(string)click," mSec");


trader88888
131
trader88888 2014.12.19 15:48  
honest_knave:

When you want to start taking screenshots, call EventSetTimer() or EventSetMillisecondTimer().

When you want to stop taking shots, call EventKillTimer()

In OnTimer(), add you code for taking screenshots.

Example: if you set EventSetTimer(1), a screenshot will be taken every second until you kill the timer.

So are you saying this? :  

 

EventSetTimer(1);
OnTimer()
{
WindowScreenShot(..)
}
EventKillTimer();

 

And then the screenshot would be taken once, and after it is the timer would be killed which would basically take a screenshot every 1 second? 

whroeder1
13610
whroeder1 2014.12.19 19:33  
trader88888:   "The Sleep() function can't be called for custom indicators".
So don't sleep, wait for time to elapse.
OnCalc(...){
   :
   static datetime sleepUntil=0;
   if(TimeCurrent() >= sleepUntil){              // Sleep time expired.
      sleepUntil = TimeCurrent() + SleepSeconds; // Reset.
      :
/
To add comments, please log in or register