int indicatorHandle = iCustom(symbol, PERIOD_M1, "MyIndicator");
..and at some later stage, I attach it to a new chart that I have created...
long chartHandle = ChartOpen(symbol, PERIOD_M1);
ChartIndicatorAdd(chartHandle, 0, indicatorHandle);
I believe the custom indicator is correctly attached to the chart because the OnChartEvent() function is correctly processing messages.
Inside the OnInit() function of the indicator, I create a 1 second timer using EventSetTimer(1), but the timer is not firing at all (OnTimer() not called).
I then wondered if it was not firing because the timer in the indicator was created and running for some time before being attached to a chart, so I modified the EA to post a message to the indicator once the indicator was attached to the chart. I then create the timer at this point...
voidOnChartEvent(constint id, constlong& lparam, constdouble& dparam, conststring& sparam)
{
if (id >= CHARTEVENT_CUSTOM)
{
ushort eventType = (ushort)(id - CHARTEVENT_CUSTOM);
if (eventType == CHART_EVENT_CREATE)
{
// TECH: This event is received when...// 1) The EA creates a new chart.// ...and...// 2) The EA attaches this event handler to the new chart.EventSetTimer(1);
}
}
}
...but still I am unable to get the timer to fire. I have checked GetLastError(), and there are no errors.
So my question is, should this work or will the OnTimer() only work in an EA?
If this should work, and I hope that it should, can someone please highlight where I am going wrong.
I have created a custom indicator using...
..and at some later stage, I attach it to a new chart that I have created...
I believe the custom indicator is correctly attached to the chart because the OnChartEvent() function is correctly processing messages.
Inside the OnInit() function of the indicator, I create a 1 second timer using EventSetTimer(1), but the timer is not firing at all (OnTimer() not called).
I then wondered if it was not firing because the timer in the indicator was created and running for some time before being attached to a chart, so I modified the EA to post a message to the indicator once the indicator was attached to the chart. I then create the timer at this point...
...but still I am unable to get the timer to fire. I have checked GetLastError(), and there are no errors.
So my question is, should this work or will the OnTimer() only work in an EA?
If this should work, and I hope that it should, can someone please highlight where I am going wrong.