I would like to 1) display on the chart a button, that 2) when clicked executes a specified function. What is the easiest way to do it?
All interaction with Chart Objects is handled by the Chart Events Handler "OnChartEvent()". You can then detect the "CHARTEVENT_OBJECT_CLICK" event and have the function handle it as you see fit.
Please, note however, that Chart Events are not emulated in the Strategy Tester and you will need to handle them in a different way (have a look this thread here and my post at the end about this point).
Please, note however, that Chart Events are not emulated in the Strategy Tester and you will need to handle them in a different way
I don't know the underlying reason, but I don't think Metaquotes will change it.
Anyway, using an indicator is a good workaround, you just need to use iCustom() in your EA.
I disagree about the use of an Indicator as a workaround or general solution to the problem. Maybe for some, but definitely not for many other cases.
In my particular case, the use of the Indicator would not achieve the desired goal. In some of my EA's I use buttons to have the EA execute certain tasks, such as placement of manual orders which the EA calculates Volume, S/L & T/P, based on several underlying conditions and then continues to monitor and manage the orders (such as trailing or closing on signal changes) while I walk away and leave it be.
That is why, I started coding it in a way, that would work with Chart Events when live but when in Visual Mode in the Strategy Tester, it would check the state of buttons manually on every tick.
To add comments, please log in or register