- MetaTrader 5 Virtual Hosting for Forex and stocks
- MetaTrader 5 Built-in Trading Strategy Tester
- MQL5 Wizard: Development of trading robots for MetaTrader 5
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.
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; }
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 . . .
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?
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?
I just found under the tools menu an item for global variables. Is that what you mean?
I just found under the tools menu an item for global variables. Is that what you mean?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use