Thanks Viffer.
Viffer, I use this
Close[j] and function...
But Now, I have othr problem, this loop is very hard for cpu...I have an Quad Core and my Cpu Use is 82% with scrypt...
Do you know if have other type for create this function? The mql4 have for exemplo a Timer as in vb.net...
My loop is hard because While causes many loop in 10 seconds...If I stop this loop too, it is ok....
If possible in any new bar the code was executed, it´s will well.
Is possible to creat an scrypt that when new bar is created in chart, execute the script?
You should use the event-driven nature of MT4 for this. Close[] will not change unless a new tick arrives; a tick is an 'event' which causes a call to start(). Hence, you should write that line to file once in every call to start() and not in a loop (this assumes you are implementing this in an EA and not in a script).
p.s. Although it's not against official forum rules, it's considered bad netiquette to 'bump' your own thread every few minutes. You made 4 posts in the same thread in less than an hour without anybody replying... Next time, if you have more info to add, you can Edit your last post on that thread...
[...] You can only use sleep in an EA, not in a script.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello.
I try save in txt the Close price.
int start()
{
//----
int _time_waiting=0;
bool tester=False;
int handle;
int j;
for (j=2; j>1; j++)
{
FileFlush(handle);
FileClose(handle);
if (tester==False)
_time_waiting = TimeLocal() + 5;
while ( TimeLocal() < _time_waiting )
{
}
// MessageBox("teste", "caption" );
handle=FileOpen("eurjpy.txt", FILE_WRITE);
if(handle>0)
{
//MessageBox("02", "caption");
FileWrite(handle, Close[0], AccountBalance( ));
}
}
//----
return(0);
}
//
My idea, was to creat an loop with for infinite, so, this loop, save the price Close ever in txt in eath 5 seconds....But not function, only save one time...