Custom Indicator not drawing when timeframe changed
You are making a gross mistake - you CREATE AN INDICATOR HANDLE AT EVERY TICK !!! This is a gross mistake! According to MQL5 style, HANDLE INDICATOR SHOULD BE CREATED ONLY ONCE and done in OnInit.
See the documentation for an example: iMA
I also recommend creating an indicator template using the 'MQL5 Wizard'.
- www.mql5.com
Please attach your code (using the button
) and a screenshot of the indicator's operation - I'm interested to see what happened.
Here it is. Just moved the handle declaration to the OnInit section.
Hi All,
I've written a test custom indicator that uses 2 MA. It drew the indicator fine when I first attached it to a chart
however when I changed the timeframe. It somehow only draw the last bar and continue from the latest bar.
Please help.
PS. There's no error in the expert tab.
Here's the code.