Pause EA in Strategy Tester to wait for SQL Server

To add comments, please log in or register
jshumaker
662
jshumaker  
I have an EA that passes a SQL command to a Microsoft SQL Server instance to execute a stored procedure.  The stored procedure takes a few seconds to process and then produces a text file.  In a live environment that should not be an issue, but when testing in Strategy Tester it is an issue.  Any suggestions on the best way to pause Strategy Tester each time the stored procedure is called so that Microsoft SQL Server has time to process the stored procedure?
Simon Gniadkowski
17274
Simon Gniadkowski  
jshumaker:
I have an EA that passes a SQL command to a Microsoft SQL Server instance to execute a stored procedure.  The stored procedure takes a few seconds to process and then produces a text file.  In a live environment that should not be an issue, but when testing in Strategy Tester it is an issue.  Any suggestions on the best way to pause Strategy Tester each time the stored procedure is called so that Microsoft SQL Server has time to process the stored procedure?
Use a Global Variable to signal to an Indicator running on a live chart that it wants a wait time,  the Indicator performs the wait ( Sleep() ) and changes the Global Variable when it is done,  when the EA in the Strategy Tester sees that the Global Variable is changed it continues. 
jshumaker
662
jshumaker  
RaptorUK:
Use a Global Variable to signal to an Indicator running on a live chart that it wants a wait time,  the Indicator performs the wait ( Sleep() ) and changes the Global Variable when it is done,  when the EA in the Strategy Tester sees that the Global Variable is changed it continues. 

I do not think I understand what you mean by 'signal to an Indicator running on a live chart that it wants a wait time'.  I have tried using the code below in a couple areas such as OnTick and before the lines of code that fill the buffers for the indicators that I use

if (waitSql==true)
   {  Sleep(10000);
      waitSql=false; }
   
Simon Gniadkowski
17274
Simon Gniadkowski  
jshumaker:

I do not think I understand what you mean by 'signal to an Indicator running on a live chart that it wants a wait time'.  I have tried using the code below in a couple areas such as OnTick and before the lines of code that fill the buffers for the indicators that I use

Sleep() does not work in the Strategy Tester.  

OK,  I should have said create an EA or Script,  Indicators shouldn't sleep . . .   and run it on a chart,  any chart.  It watches the Global Variable that your EA running in the Strategy Tester writes,  it writes a 1.0 when it wants a delay, and sits in a loop waiting for the Global Variable to change to a value less than 0.5.  The EA/Script sits in a loop looking at the Global variable and when it sees it go above 0.6 it waits a predetermined number of seconds  ( Sleep(number_of_seconds * 1000) )  and then sets the Global variable to 0.0 . . .  the EA in the Strategy Tester will see this and then resume running . . .  it has been delayed by number_of_seconds . . .  which is what you asked for.

I have coded this before in mql4 and it works . . .  you can try it in mql5 and let us know how it works for you . . .  by the way,  if you use a Script you won't need ticks . . . 

jshumaker
662
jshumaker  
RaptorUK:

Sleep() does not work in the Strategy Tester.  

OK,  I should have said create an EA or Script,  Indicators shouldn't sleep . . .   and run it on a chart,  any chart.  It watches the Global Variable that your EA running in the Strategy Tester writes,  it writes a 1.0 when it wants a delay, and sits in a loop waiting for the Global Variable to change to a value less than 0.5.  The EA/Script sits in a loop looking at the Global variable and when it sees it go above 0.6 it waits a predetermined number of seconds  ( Sleep(number_of_seconds * 1000) )  and then sets the Global variable to 0.0 . . .  the EA in the Strategy Tester will see this and then resume running . . .  it has been delayed by number_of_seconds . . .  which is what you asked for.

I have coded this before in mql4 and it works . . .  you can try it in mql5 and let us know how it works for you . . .  by the way,  if you use a Script you won't need ticks . . . 

How do I get Strategy Tester to watch the global variable in the EA?
jshumaker
662
jshumaker  
jshumaker:
How do I get Strategy Tester to watch the global variable in the EA?
I just found under the tools menu an item for global variables.  Is that what you mean?
Alain Verleyen
40787
Alain Verleyen  
jshumaker:
I have an EA that passes a SQL command to a Microsoft SQL Server instance to execute a stored procedure.  The stored procedure takes a few seconds to process and then produces a text file.  In a live environment that should not be an issue, but when testing in Strategy Tester it is an issue.  Any suggestions on the best way to pause Strategy Tester each time the stored procedure is called so that Microsoft SQL Server has time to process the stored procedure?
As your Stored Procedure create a text file, one solution could be to loop until your EA find the created file.
Simon Gniadkowski
17274
Simon Gniadkowski  
jshumaker:
I just found under the tools menu an item for global variables.  Is that what you mean?
Global Variables
Simon Gniadkowski
17274
Simon Gniadkowski  
jshumaker:
I just found under the tools menu an item for global variables.  Is that what you mean?
Sorry,  this isn't going to work . . . Global variables inside the Strategy Tester != Global Variables outside the Strategy Tester  
To add comments, please log in or register