Download MetaTrader 5

Debugger: How to debug on my chart instead of an arbitrary chart created by debugger?

To add comments, please log in or register
Publish your application in the Market - 7 million potential clients will see it
williamwong
632
williamwong 2010.08.05 13:39 

My indicator uses vertical lines drawn on the chart to determine the start and end dates use to compute instead of specifying them through the input parameters.  This is more intuitive for user to drag the vertical lines to specific the range to study instead of reload the indicator and respecifying the dates.

The problem is when I launch the debugger, it actually debugs on a new chart of its own without the vertical lines.  How can I config the debugger to debug on the chart I created instead?

Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Types - Documentation on MQL5
Alexey Da
Moderator
6606
Alexey Da 2010.08.05 16:01  
williamwong:

How can I config the debugger to debug on the chart I created instead?

 

 

Unfortunatelly you can't, but you have workarounds:

1. The best way is doing check in OnCalculate function of your indicator. Indicator should check for existing of vertical lines on the chart and do nothing when lines aren't exist.

2. When the new charts window is opening in terminal, template from file "Default.tpl" (if file is exist) will automatically applied for new chart. So you can save chart template with two vertical lines into file "Default.tpl". This template will be applied for chart window which will be opened by editor. You also can save your own template  into any file and apply it for the chart using ChartApplyTemplate() function.

3. You can place the call of function DebugBreak() at the beginning of function OnInit. When you run your indicator in debug mode the breakpoint will be triggered and execution will paused. So you will have your time to place vertical lines on the chart. After that you should continue execution of your indicator.

williamwong
632
williamwong 2010.08.06 09:58  
alexvd:

 

2. When the new charts window is opening in terminal, template from file "Default.tpl" (if file is exist) will automatically applied for new chart. So you can save chart template with two vertical lines into file "Default.tpl". This template will be applied for chart window which will be opened by editor. You also can save your own template  into any file and apply it for the chart using ChartApplyTemplate() function.

I managed to work around setting breakpoint in Oninit.  I also tried ChartApplyTemplate(), the debugger just terminates.  I hope you can add the feature for debugger to attach to any chart, this is especially helpful to debug expert/script/indicator that interact with the objects there are already in the chart.
Alexey Da
Moderator
6606
Alexey Da 2010.08.06 13:36  
williamwong:
I managed to work around setting breakpoint in Oninit.  I also tried ChartApplyTemplate(), the debugger just terminates.  I hope you can add the feature for debugger to attach to any chart, this is especially helpful to debug expert/script/indicator that interact with the objects there are already in the chart.

We made auto applying of template from file "Debug.tpl" for charts which is opening in debug.

To add comments, please log in or register