
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Please advise why two indicators with identical mq4 code produce different picture on the chart? More precisely, what is the methodolody of indicator development, for two lines (one drawn in real-time and one produced by calculating completed bars) would be the same? Here is the screenshot I've got:
http://dev.webie.ru.fox.mtw.ru/.chucha/trading/JMA-unsync.png
Aqua line - this indicator was running 2 days long, was dropped and left unchanged since 2 days ago. I didn't update its properties, no changes in parameters, no recompilation, so there was no reason to interrupt the algorithm. Purple line is the same indicator (a copy), but dropped into the chart right now. The spot where two lines start to be different is the moment when Aqua JMA began to receive start() callback from MT4 on every incoming tick.
Observations: the lines from simple indicators don't have any difference (like Moving Average of any kind). JMA lines are different. There are some "unique" developments like RSX which changes the line all the way backward when depending on incoming tick some distant point located 10 bars ago, starts jumping around... But I have in my indicator the same issue like in JMA shown above and I can't understand how I can fix it.
How to reproduce the issue:
1. download the code of the indicator and put in well known folder for MT4 as JMA.mq4 :
http://www.abysse.co.jp/mt4/indicators/JMA%20%5Bi%5D.mq4
(or here http://www.abysse.co.jp/mt4/indicator_name_j.html >> "JMA square_bracket i square_bracket.mq4" )
2. make a copy of this indicator, naming this copy as JMA2.mq4 ;
3. to create new chart (delete everything, make it clean), drop JMA.mq4 on the chart ;
4. wait for 2 days, drop JMA2.mq4 on the same chart;
5. see the difference.
6. you can launch an optimization for any expert advisor (visual test with tick modeling). launch test, pause it, drop first JMA, release pause, let 20 bars to appear, pause it again, drop the second JMA.
I assume that the answer to my question "how shall I develop my indicator so the lines drawn wouldn't become different between realime bars and completed past bars?" must be somewhere here:
1. MT4 interrupts sometimes and announces "waiting for update" on the chart, so it's not documented what exactly happens with the indicator methods invocation. does MT4 invokes init()? does MT4 invokes start()? when? does MT4 invokes start() once for all bars or it invokes start() individually for each bar which had changed due to "update"? in that case, the solution comes here: ...
2. the indicator is developed with volatility collected during the bar being under completion. for a completed bar, start() is invoked once, but for current bar start() will be invoked for each incoming tick (change of quotes); so, at some point something extra is collected somewhere because of multiple start() calls on non-completed bar and a glitch occurs; for that case, the solution is here: ...
Thank you very much for any of your suggestions!