Drag and drop SL and TP in the tester.

 
Is it possible to create such a feature to drag SL and TP on the chart during testing?
 
khorosh:
Is it possible to create such a possibility to drag SL and TP on the chart during testing?
Only virtual ones - with horizontal lines. Set lines instead of take and loss, and use them to make exits.
 
Vitaly Muzichenko:
Only virtual ones - with horizontal lines.
I think you can. I have a rough idea of the possible variant but we have to try and check it. For example, I already use order placement during testing by dragging the script to a certain point of the chart. I think we should use theCHARTEVENT_CLICK eventto run the script wherewe should read cursor coordinates and use that data to modify an order.
 
khorosh:
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?

 
Alexey Volchanskiy:

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

Files:
TP.ex4  731 kb
 
Alexey Volchanskiy:

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.

 
Vitaly Muzichenko:

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. "

I have control buttons in the indicator standing and usingOnChartEvent . Everything works.
Документация по MQL5: Основы языка / Функции / Функции обработки событий
Документация по MQL5: Основы языка / Функции / Функции обработки событий
  • www.mql5.com
Основы языка / Функции / Функции обработки событий - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
khorosh:

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?
 
Alexey Volchanskiy:
Do you have an Expert Advisor for MT4 or MT5?
MT4. I do not trade in MT5.
 
khorosh:
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.

 
Alexey Volchanskiy:

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.