Detecting a "visual" chart

 

I wonder if someone knows a way how to detect a 'visual' chart launched by the Strategy Tester using a pure MQL. I would like to prevent running my scripts on such a chart, as the chart does not update graphic objects with ChartRedraw(). The IsVisualMode returns false in scripts, and saved chart template indicates nothing about the visual mode.

 
What about checking the time? If the first TimeCurrent() is too far away from TimeLocal() - more than a couple of hours?
 
gooly:
What about checking the time? If the first TimeCurrent() is too far away from TimeLocal() - more than a couple of hours?
I will try, though I doubt it makes sense - the TimeCurrent should be tampered only in the tester thread, which is not the case here.
 
Ovo:
I will try, though I doubt it makes sense - the TimeCurrent should be tampered only in the tester thread, which is not the case here.
Yes, times have current values.
 

Ok I just read: "During testing in the Strategy Tester, TimeLocal() is always equal to TimeCurrent() simulated server time."

So you can use some WinApi-funtions - like GetSystemTime?

 
gooly:

Ok I just read: "During testing in the Strategy Tester, TimeLocal() is always equal to TimeCurrent() simulated servertime."

So you can use some WinApi-funtions - like GetSystemTime?


With winapi it is easy - I would simply read the window bar title and check for the word "visual". I was looking for a pure MQL solution without DLLs, but it seems unlikely there is any.
 
Ovo:
I wonder if someone knows a way how to detect a 'visual' chart launched by the Strategy Tester using a pure MQL. I would like to prevent running my scripts on such a chart, as the chart does not update graphic objects with ChartRedraw(). The IsVisualMode returns false in scripts, and saved chart template indicates nothing about the visual mode.

I just did a short test on my setup (build 988) and these were my results:

  • Indicators:

Indicators, when added to the "Visual Chart", are in fact detected by the Strategy tester and the "IsVisualMode()" does report correctly, but I do not know how much of the data and functions are correctly processed in emulated/simulated mode.

  • Scripts:

It seems that adding a Script to the "Visual Mode" Chart is not detected by the Strategy Tester at all and consequently data is not emulated/simulated. In fact, any data such as Bid or Ask or calls to functions like MarketInfo() or OrdersTotal() for example, obtain the current "live" values and not the emulated/simulated values in the Strategy Tester.

So, in conclusion, even if you were able to detect if it was on the "Visual Chart" or not, the results obtained in the Script or manipulations of data or orders would report to the "live" state of things and not that of the emulated/simulated conditions in the Strategy Tester.

My suggestion is to give your customers this warning:

WARNING - NEVER attach Scripts to the Visual Chart as the results will reflect on the "live" chart and not the simulation. This is especially DANGEROUS if the Script manipulates Orders.

 
FMIC:

I just did a short test on my setup (build 988) and these were my results:

  • Indicators:

Indicators, when added to the "Visual Chart", are in factdetected by the Strategy tester and the "IsVisualMode()" does reportcorrectly, but I do not know how much of the data and functions arecorrectly processed in emulated/simulated mode.

  • Scripts:

It seems that adding a Script to the "Visual Mode" Chart is not detected by the Strategy Tester at all and consequently data is not emulated/simulated. In fact, any data such as Bid or Ask or calls to functions like MarketInfo() or OrdersTotal() for example, obtain the current "live" values and not the emulated/simulated values in the Strategy Tester.

So, in conclusion, even if you were able to detect if it was on the "Visual Chart" or not, the results obtained in the Script or manipulations of data or orders would report to the "live" state of things and not that of the emulated/simulated conditions in the Strategy Tester.

My suggestion is to give your customers this warning:

WARNING - NEVER attach Scripts to the Visual Chart as the results will reflect on the "live" chart and not the simulation. This is especially DANGEROUS if the Script manipulates Orders.

Thank you for the report. Actually the main reason I was trying to avoid the "visual" charts was, that they did not update graphical objects (I specified information in the first post). So using script interaction via GUI becomes tricky.
 
Ovo:
Thank you for the report. Actually the main reason I was trying to avoid the "visual" charts was, that they did not update graphical objects (I specified information in the first post). So using script interaction via GUI becomes tricky.
Yes, I did read the first post and I do understand that your first concern was the GUI interaction. However, I was just bringing to your attention that there are other problems and dangers in using Scripts on the Visual Chart because they interact with the real/live account and not with the emulated/simulated account. So, even if you could resolve the GUI issue, it would still not be advisable to use Scripts on the Visual Chart.