EA Processing Time

 
I'm in the early stages of writing a new EA and I am shocked by the variability in the processing time. For example, I am currently calculating and printing only two MA's and sometimes it takes only 1 second, then sometimes it takes 24 seconds. My guess is the EA must interact with the broker's server in order to obtain the MA value and that is why it takes so long sometimes. If that is the case it is no small wonder why we get big requotes when you are ready to execute a trade. That kind of delay in just obtaining the MA value does not bode well for the overall performance time when the EA is completed. Any thoughts on this?
 

The only operations that "go to the server" are OrderSend(), OrderModify(), and OrderDelete(). Everything else is handled locally/invisibly.

 
phy:

The only operations that "go to the server" are OrderSend(), OrderModify(), and OrderDelete(). Everything else is handled locally/invisibly.

Thanks for the reply phy --- however, I am surprised by your response. I have a pretty fast computer, and I am surprised that it takes between 1 and 24 seconds to process a short EA with only two function statements in it and two print statements. I frankly don't understand the variability in time, and that is why I was suggesting that the MA value must be retrieved from the broker's server. Any thoughts on why my computer is theoretically so erratic? Everything else works pretty smoothly. It can process a large spreadhseet with a 100,000 equations in a few seconds and do so in a consistant timeframe.

 
phy:

The only operations that "go to the server" are OrderSend(), OrderModify(), and OrderDelete(). Everything else is handled locally/invisibly.

 

I was initially trying to figure out the "shift" parameter in the iMA function, so I wrote a little script to retrieve the MA value when the "shift" was 1 and when it was 5. I threw in the Sleep() function, so it would retrieve the MA's only once every 60 seconds. What I discovered is disturbing. The processing time for this inconsequential script takes between 0 seconds and 42 seconds if you do not count the 60 seconds of sleep time.


If that is the best MT4 can do with respect to processing time, it is no small wonder that we get big requotes from the broker's server, if the program is that erratic and takes that long to process simple statements. The program simply cannot take that kind of time to evaluate incoming quotes and related market data and still get timely quotes.


Any thoughts on why the EA is so erratic?

 
FXtrader2008 wrote >>

I was initially trying to figure out the "shift" parameter in the iMA function, so I wrote a little script to retrieve the MA value when the "shift" was 1 and when it was 5. I threw in the Sleep() function, so it would retrieve the MA's only once every 60 seconds. What I discovered is disturbing. The processing time for this inconsequential script takes between 0 seconds and 42 seconds if you do not count the 60 seconds of sleep time.

If that is the best MT4 can do with respect to processing time, it is no small wonder that we get big requotes from the broker's server, if the program is that erratic and takes that long to process simple statements. The program simply cannot take that kind of time to evaluate incoming quotes and related market data and still get timely quotes.

Any thoughts on why the EA is so erratic?

I know that when a program prints anything, that output kills the performance. In Matlab, for example, when it is calculating basic image filters without outputting data, it takes 500ms to complete, but when printing outputs are enabled, the performance goes to 30seconds. MT4 is very fast, behind the scenes. This is the case of what you see is not what you get!

BTW: why are you so worried, are you running a high frequency system?

 

Your code runs when a tick is received.

waiting for first tick...

ima

print

sleep 60000

waitng for another tick.... can take a while, sometimes.

tick received

ima

print

sleep 60000

waitng for another tick.... can take a while, sometimes.

 
phy:

Your code runs when a tick is received.

waiting for first tick...

ima

print

sleep 60000

waitng for another tick.... can take a while, sometimes.

tick received

ima

print

sleep 60000

waitng for another tick.... can take a while, sometimes.

phy --- I appreciate your response very much. Even though I am aware that the program does not run until a new tick is received, I did not think it through as clearly as you stated in your reply. Thanks again for your reply.

 
c0d3:

I know that when a program prints anything, that output kills the performance. In Matlab, for example, when it is calculating basic image filters without outputting data, it takes 500ms to complete, but when printing outputs are enabled, the performance goes to 30seconds. MT4 is very fast, behind the scenes. This is the case of what you see is not what you get!

BTW: why are you so worried, are you running a high frequency system?

c0d3 --- Thank you for your kind reply. I am in the early stages of writing a new EA and want to be as efficient as possible in the program logic to avoid unnecessary runtime. I was devastated when I saw only a few simple functions taking as much as 42 seconds to complete. Obviously I do not want my EA to take anything near 42 seconds to evaluate an incoming quote for potential trade launch; if it takes that long I will also obviously get a requote if I try to launch a trade on a quote that is 42 seconds old. So that was my concern with respect to runtime.


I appreciate your insight regarding the output function. I was beginning to suspect that function was the culprit. I have placed TimeLocal() functions in front of, and in back of, the various program function statements to determine which one is taking so long. I was just about to isolate the "Print" function that way when I decided to check this forum for any responses.


One last question --- You mentioned a runtime of "500ms" in your response --- how do you obtain runtime feedback in milliseconds? Thanks again for taking the time to respond to my inquiry.

Reason: