Update only once a minute - page 2

 
IntraTrade:


Thank you for your replies...

But If I use for ex. "CHFJPY", there is a tick every minute (somewhere), then I could hold on to that tick and force MT4 to wait for a new minute. When a new minute begins I read all data for the previous minute (for all diffrent quotes) and Export it to MySQL. This works but MT4 freezes during my WHILE-loop and thats why I want to "Do Events" while waiting for a new minute.

I don´t use brokertime I use systemtime...

Any Ideas?


Why do you want to start at second "00" The data for the previous minute can't have been changed at the seconds after "00".

I like to do but I can't go back in history. If you can please tell me how....

 

This is probably the solution...

Now I am going to do some research about "scripts" and "EA" because I have only made indicators...

Thank you for your quick response!

 
deVries:


Why do you want to start at second "00" The data for the previous minute can't have been changed at the seconds after "00".

I like to do but I can't go back in history. If you can please tell me how....


The whole minute has to pass before I export the data to my sql-database. So when the time of the current minute is 0 seconds, I export the previous minute to my database...

I use in my indicator script "Close [1]" because it is the previous minute. If you use Close[0] this is the last close occured (could be in previous minute or in this minute).

I export Time, Close, Open, High, Low, Volume. I also export in different timeframes 1min, 5min, 15min, 30 min, 60min. I know this is unnecessary, but I want my SQL-questions to be fast and easy (I´m neither a SQL or a MT4 guru).

My next projekt is to add some indicator values (that I can´t calculate from SQL) and the timeframes 240 min and 1 day.

 
if (NewBar() == false) return(0);

and if not ...... first tick new is true export your data

//+------------------------------------------------------------------+
//| NewBar                                                           |
//| Returns true when new bar gets first tick                        |
//| Returns false otherwise                                          |
//+------------------------------------------------------------------+
bool NewBar()
{
   static datetime dt = 0;
   
   if (Time[0] != dt)
   {
      dt = Time[0];
      return(true);
   }
   return(false);
}

And the data of the previous minute will be exported

And about Close[0] that is Bid and can be changed as long as the minute is still happening

by the way the last day of this year is at this moment 15 oktober 2011

I may hope we get tomorrow and that the year is not over yet

 

Thanks to your reply and the submitted example!

As I described earlier in this threed. I want the database to get the data as quickly as possible (but not ticks).

I don´t know where the new-minute-tick will come. And I´m exporting up to 23 diffrent quotes in only one indicator. I wan´t the execution at 0 seconds and force all data be collected at the same time. Sorry if I´m stubborn, but it has to be this way to feed my external algo.

So my next question is to convert my indicator to an EA. I want to do this to use the "Sleep" function...

My question is:

What has to be done in the header for MT4 to understand it´s an EA?

- I know this line has to be deleted " #property indicator_chart_window". Oterwise I can´t see the difference...

Could I still use "Init", "Start" and "deinit"?

- It would be easy to test this if it was´t saturday evening...

 

RaptorUK:

Nope . . . MT4 is tick driven


Didn't did answer you..... on your question earlier

IntraTrade:


Is there a function for executing this chart/indicator or EA every minute on second "00" even though there is not tick?

Why should it be now different

 

Solved. I change it from an Indicator to an EA and used the sleepfunction. It freezes no more :-)

 

Regarding the initial inquiry, I use a software tool for developing my visual indicators and running code when the markets are closed.

It helps test indi's on weekends that normally require live ticks.

It will send ticks allowing code to execute even though there are no live ticks.

It may well suit your purpose. I find it invaluable.

My comments re my own use are at

http://www.brooky-indicators.com/?p=401

Cheers

Brooky

Reason: