Download MetaTrader 5

mql5 and metaeditor problem

To add comments, please log in or register
Looking for like-minded people? You will find lots of them on the Forum!
makset
24
makset 2014.04.05 11:47 

Hello

I want to emphasize at the outset that I am a novice in mql5.

I have the following problem:

- I just wish my expert system exported my data to a txt file every minute but exactly on time 55 seconds, eg 1.55, 2.55, 3.55 and so on. I do not want to use the onTick section because not every second transaction is realized, I need timer or something else. So far, I used to schedule tasks with the following vbs file:

Set WshShell = WScript.CreateObject("WScript.Shell")
Set oShell = CreateObject("WScript.Shell")
rem oShell.SendKeys "% (s)"
WshShell.AppActivate "metaeditor"
WshShell.SendKeys "{f7}"
WshShell.SendKeys "^s"
oShell.SendKeys "% (m)"

f7 run compiler with own indicator.

but it is a very ineffective way.

Further when the export file is closed MQL runs the bat file.



Thank for your help.


Rodrigo Malacarne
Moderator
9889
Rodrigo Malacarne 2014.04.05 12:34  
makset:

Hello

I want to emphasize at the outset that I am a novice in mql5.

I have the following problem:

- I just wish my expert system exported my data to a txt file every minute but exactly on time 55 seconds, eg 1.55, 2.55, 3.55 and so on. I do not want to use the onTick section because not every second transaction is realized, I need timer or something else. So far, I used to schedule tasks with the following vbs file: 

f7 run compiler with own indicator.

but it is a very ineffective way.

Further when the export file is closed MQL runs the bat file.

Thank for your help.

Have you seen the OnTimer( ) event handler

Alain Verleyen
Moderator
30640
Alain Verleyen 2014.04.05 13:21  
makset:

Hello

I want to emphasize at the outset that I am a novice in mql5.

I have the following problem:

- I just wish my expert system exported my data to a txt file every minute but exactly on time 55 seconds, eg 1.55, 2.55, 3.55 and so on. I do not want to use the onTick section because not every second transaction is realized, I need timer or something else. So far, I used to schedule tasks with the following vbs file:

Set WshShell = WScript.CreateObject("WScript.Shell")
Set oShell = CreateObject("WScript.Shell")
rem oShell.SendKeys "% (s)"
WshShell.AppActivate "metaeditor"
WshShell.SendKeys "{f7}"
WshShell.SendKeys "^s"
oShell.SendKeys "% (m)"

f7 run compiler with own indicator.

but it is a very ineffective way.

Further when the export file is closed MQL runs the bat file.



Thank for your help.


You can use the timer events, as suggested by Malacarne. However, the timer can run your code every minute, there is no way to control when it start, so you cannot be sure to run it at 1.55, 2.55, etc...

I let you think about that. Feel free to ask if you can't find how to deal with that

Rodrigo Malacarne
Moderator
9889
Rodrigo Malacarne 2014.04.05 22:24  
josemiguel1812:

Utilice OnTimer () con EventSetTimer (1)

Good approach... However, you should also explain how your newBar() function works...
Jose Miguel Soriano
4957
Jose Miguel Soriano 2014.04.05 22:24  
makset:

Hello

I want to emphasize at the outset that I am a novice in mql5.

I have the following problem:

- I just wish my expert system exported my data to a txt file every minute but exactly on time 55 seconds, eg 1.55, 2.55, 3.55 and so on. I do not want to use the onTick section because not every second transaction is realized, I need timer or something else. So far, I used to schedule tasks with the following vbs file:

Set WshShell = WScript.CreateObject("WScript.Shell")
Set oShell = CreateObject("WScript.Shell")
rem oShell.SendKeys "% (s)"
WshShell.AppActivate "metaeditor"
WshShell.SendKeys "{f7}"
WshShell.SendKeys "^s"
oShell.SendKeys "% (m)"

f7 run compiler with own indicator.

but it is a very ineffective way.

Further when the export file is closed MQL runs the bat file.



Thank for your help.


Use OnTimer() with EventSetTimer(1).

The following code is a solution to lack of control the first entry that does not have to coincide with start of bar

void OnTimer()
{
   int static contTime= 0;
   contTime= newBar(PERIOD_M1)? 0: contTime++;
   if(contTime==55) make...
   return;
}
Alain Verleyen
Moderator
30640
Alain Verleyen 2014.04.05 22:56  
josemiguel1812:

Use OnTimer() with EventSetTimer(1).

The following code is a solution to lack of control the first entry that does not have to coincide with start of bar

And what if there is a missing bar ?
Jose Miguel Soriano
4957
Jose Miguel Soriano 2014.04.05 23:42  
angevoyageur:
And what if there is a missing bar ?

The deformation of the programmer... who strives for perfection.

What do you do working at this hour? 

Alain Verleyen
Moderator
30640
Alain Verleyen 2014.04.06 00:17  
josemiguel1812:

The deformation of the programmer... who strives for perfection.

What do you do working at this hour? 

makset
24
makset 2014.04.07 11:08  
I am positively surprised by the fast response :) Really !!!

I will try once again to present my plan
I need a way to export the data and run the bat file in the specified time, for example 12.00.55, 12.01.55 As I wrote earlier.
I have a few ideas:
-so far I've done this using a vbs script to run the compiler metaedytor that run indicator that exported the data and run the bat file.
Maybe exist another way to do it e.g.
*expert advisor to compile indicator at a specific time (if this is possible!)
*expert advisor for a specific time exports data and runs the bat file.
*for example, a java program using the communication interface MetaEditor (if there is) run indicator.
-I also tried to run the bat file: "C:\Program Files\FxPro - MetaTrader 4\mql.exe" "C:\Program Files\FxPro - MetaTrader 4\MQL4\Indicators\testW2.mq4" /i:"C:\Program Files\FxPro - MetaTrader 4\MQL4" but does not work!.

I have no more ideas

I am a beginner in MQL (general in programming also) so please write as simple as possible with full progrma (not clippings).

I am very grateful for any help.
Alain Verleyen
Moderator
30640
Alain Verleyen 2014.04.07 15:49  
makset:
I am positively surprised by the fast response :) Really !!!

I will try once again to present my plan
I need a way to export the data and run the bat file in the specified time, for example 12.00.55, 12.01.55 As I wrote earlier.
I have a few ideas:
-so far I've done this using a vbs script to run the compiler metaedytor that run indicator that exported the data and run the bat file.
Maybe exist another way to do it e.g.
*expert advisor to compile indicator at a specific time (if this is possible!)
*expert advisor for a specific time exports data and runs the bat file.
*for example, a java program using the communication interface MetaEditor (if there is) run indicator.
-I also tried to run the bat file: "C:\Program Files\FxPro - MetaTrader 4\mql.exe" "C:\Program Files\FxPro - MetaTrader 4\MQL4\Indicators\testW2.mq4" /i:"C:\Program Files\FxPro - MetaTrader 4\MQL4" but does not work!.

I have no more ideas

I am a beginner in MQL (general in programming also) so please write as simple as possible with full progrma (not clippings).

I am very grateful for any help.

You already received an answer on how to run a code every minute within mql5 (also valid for mql4), so what is the problem to use it ? Maybe the solution isn't clear enough ?

Really, I don't understand why you are asking again when you already got a response.

Please also note the following...

Forum on trading, automated trading systems and testing trading strategies


Hello,

This forum is about MT5/mql5, please post your question about MT4/mql4 on mql4.com forum.

  • They are more people who can answer there.
  • They are more people who can have similar problem there.
  • A forum is not only to get help but to share with the community, mql4/MT4 community isn't the same as mql5/MT5 community.

makset
24
makset 2014.04.08 13:37  

I understand you but the solution was not satisfactory for me and I wanted to better explain the problem.

I think my program is better.

void OnTimer()
 {
 
 string tts = TimeToStr(TimeLocal(), TIME_SECONDS);
 string ttss = StringSubstr(tts,6,-2);
 long ttssi = StringToInteger(ttss);
 
   //int static contTime = 0;
  // if (PERIOD_M1 == 0) contTime = 0;  else
 
   if (ttssi == 55) ShellExecuteW(0,0,"____experbat.bat","","d:\\fx\\code\\",1) ;
  
  Print("--",ttssi );
   return;
}
Please evaluate them.

I have another question

it is possible that an expert advisor called (compile) indicator?


12
To add comments, please log in or register