Is it possible to create such a possibility to drag SL and TP on the chart during testing?
Only virtual ones - with horizontal lines.
I think it is possible. I can approximately imagine a possible variant, but we should try and check it. For example, I already use order placement during testing by dragging the script to a necessary point on a chart. I think we should use theCHARTEVENT_CLICK eventto run the script wherewe should read mouse coordinates and use this data to modify an order.
The OnChartEvent doesn't work in the tester. But there are some ideas how to do it.
I've posted my project on trading in the tester to the blog, I may try to add modification of SL and TP. The question is how to specify for which order we set points and stops? Do I have to first click on order lines?
OnChartEvent doesn't work in the tester. But there are some ideas how to do it.
I've posted my project on trading in the tester to the blog, I may try to add modification of SL and TP. The question is how to specify for which order we set points and stops? First click on the order lines?
Look at how we recognize the position the order belongs to. I will not lay out the source code but the matter is clear without it. Put it in the "Experts" folder
TheOnChartEvent doesn't work in the tester. But there are some ideas how to do it.
I've posted my project on trading in the tester to the blog, I may try to add modification of SL and TP. The question is how to specify for which order we set points and stops? First click on order lines?
It does not work. I have buttons on a chart in the tester that control the EA for manual trading. The event of clicking the button usesOnChartEvent. I am testing strategies in visual mode.
Yes."When testing in an Expert Advisor, you can process custom events using theOnChartEvent()function, but in indicators this function is not called in the tester. Even if an indicator hasOnChartEvent() handler and this indicator is used in an Expert Advisor under test, the indicator itself will not receive any custom events. "
![Документация по MQL5: Основы языка / Функции / Функции обработки событий Документация по MQL5: Основы языка / Функции / Функции обработки событий](/i/community/logo_mql5_small.png)
- www.mql5.com
How does it not work. I have buttons on the chart in the tester that control the Expert Advisor for manual trading. The event of pressing the button usesOnChartEvent. I test strategies in visual mode.
Do you have an Expert Advisor for MT4 or MT5?
MT4. I do not trade in MT5.
Ok, I'll check again tomorrow. Looked in the help 950 build, all restrictions are still there.
----------------------------------------- from help VN4 950 build ----------------
MQL4 Handbook / MQL4 Programs / Features of Programs in the Strategy Tester
Events Handling in the Strategy Tester
The following events are handled in the strategy tester: EA initialization before a single run OnInit(), deinitialization of an EA after a single run OnDeInit(), simulation of a new tick OnTick().
In addition, when an Expert Advisor has been tested on historical data, the Tester event is generated before OnDeInit() is called, and it is handled in the OnTester() function. The value returned by this function is used as the Custom max criterion when optimizing input parameters.
Timer and ChartEvent events are not supported in the strategy tester.
---------------------------------------
I have a separate mode for the tester, I monitor state of buttons by OnTick.
Ok, I'll check again tomorrow. Looked in the help 950 build, all restrictions are still there.
----------------------------------------- from help VN4 950 build ----------------
MQL4 Handbook / MQL4 Programs / Features of Programs in the Strategy Tester
Events Handling in the Strategy Tester
The following events are handled in the strategy tester: EA initialization before a single run OnInit(), deinitialization of an EA after a single run OnDeInit(), simulation of a new tick OnTick().
In addition, when an Expert Advisor has been tested on historical data, the Tester event is generated before OnDeInit() is called, and it is handled in the OnTester() function. The value returned by this function is used as the Custom max criterion when optimizing input parameters.
Timer and ChartEvent events processing is not supported in the strategy tester.
---------------------------------------
I have made a separate mode for my tester, I monitor state of buttons by OnTick.
There are many things which are not supported by the help. When tested, for instance, from an Expert Advisor, time series of other TFs are read normally but when called from an indicator, they show values that they had at the moment of test start. I don't know, maybe I don't understand these events correctly, as I'm not a professional proger. But in my case when I press the button a certain code is assigned to a global variable of the terminal, the code is decrypted in the Expert Advisor and used for a certain operation. And it works in exactly the same way, both in the tester and in real life. I have made the buttons in the indicator, although I suppose it could have been done directly in the Expert Advisor. The indicator is more convenient because I don't need to create buttons in each EA, one indicator is enough.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use