I think I found a bug in the ST

 

I ran an Optimization a couple of days ago, it had 385 runs, when it had finished I ran the best result on visual mode to see what the trades looked like. The end result was very much different to that given in the Optimization . . so I ran the single run again but this time with Visual mode turned off, this time I got results that matched the Optimization run.

So I set Visual mode back on and started turning different things off in my code by way of parameter values, I set the debug level to 0 to minimise writing to the log, same effect, next I turned off chart grabs . . . when I have a trade completed I can get my code to take a chart grab . . . well when I turned this of I get the correct number of trades being taken and the correct account balance at the end of the run.

I only noticed this problem this week as I have started running M15, usually I run H1 and haven't seen this problem. The reason this doesn't occur with Visual mode turn off is that my code checks for this using IsVisualMode and only takes chart grabs when Visual mode is enabled.

My Chart Grab function uses a couple of Global variables, one to keep track of file number and a second to keep track of the date, it uses WindowScreenShot as the function to take the actual grab.

 
I ran into this Bug when I was new. Back then I assumed it was because I was using open prices instead of tick. My guess as to why it happens is because of Speed issues similar to having excessive prints statements but mt4 only printing some of them. Perhaps Rosh will see this and MQ will fix in future updates.
 
ubzen:
I ran into this Bug when I was new. Back then I assumed it was because I was using open prices instead of tick. My guess as to why it happens is because of Speed issues similar to having excessive prints statements but mt4 only printing some of them. Perhaps Rosh will see this and MQ will fix in future updates.


I'm using every tick, I hope Rosh or some other Metaquotes person will see this thread, I'm happy to explain anything that needs further explanation or any other testing that needs doing to help replicate this issue or test a solution.

In the future I am more likely to need to run the ST on timeframes lower than H1 and for my particular EA seeing the trades by way of chart grabs is incredibly useful.

 
One more thing, this was on version 409.
 
You did all the testing in offline mode, didn't you?
 
zzuegg:
You did all the testing in offline mode, didn't you?
Yep, I always do ;-)
 
I built a delay of 5 seconds into my EA to allow time for the chart grab to happen . . . it's not helping, anyone have any good ideas ?
 

I have tried a new approach today . . . I have added code so that my EA will send a Ctrl + Shift + L and used this as a hotkey combination to trigger and external application which is setup to take a screen grab of a preset area of the screen . . the chart window . . . it works but when there are several trades in quick succession the external app just can't keep up.

I've tried a few, Snagit, FSCapture, MWSnap3 . . .

 

False alarm . . . sorry.

Looks like this "bug" was a problem in my code.

Funny thing is I think I found a way around it . . . :-) and now I don't need to.

 
It's possibly too late to update the original post. So what was the problem in the code?
 
ubzen:
It's possibly too late to update the original post. So what was the problem in the code?

Yep it is too late to edit the first post, I have notified BarrowBoy and Rosh.

The problem in hindsight was very simple, isn't that usually the way.

I had a block of code that was executed, if (Chart_Grabs) . . ( Chart_Grabs is an extern ) . . so if I wanted chart grabs of all the trades I set this to true. In this block of code is some code to find the most recent closed trade and to do a grab if it hadn't been grabbed already . . . so far so good.

At some point during the evolution of my EA I had added into this block something which was nothing to do with the chart grab . . . it was a change in a bool to false . . . it was this that was making the difference in the number of trades but was only noticeable when Chart_Grabs was set from true to false or visa versa, so in error I reasoned that the problem was caused by the chart grab itself . . .

Live and learn, try not to make the same mistake again.

Reason: