None of my business but you have an issue in your code : It does not update most recent bars (any bar that is created after the initial run) correctly nor is the current bar updated at new ticks at all
That same issue exists in all your indicators posted at the code base
Yes I had this problem with some of my codes, but now I have just checked the iCCI and it is good on my side in M1.
The problem was with the signature of the copybuffer, but this one was good
i_Diff = rates_total - prev_calculated; if ( CopyBuffer ( g_PtCCI, 0 , 0 , i_Diff, g_BufferCCI) < 0 ) { PrintFormat ( "%s; Error %d in data recovery" , __FUNCTION__ , GetLastError ()); return ( 0 );I'm going to check all my codes to be sure, I may have missed one.
Beautiful evening
Hello and thank you for your feedback
Yes I had this problem with some of my codes, but now I have just checked the iCCI and it is good on my side in M1.
The problem was with the signature of the copybuffer, but this one was good
I'm going to check all my codes to be sure, I may have missed one.
Beautiful evening
i_Diff = (prev_calculated>0) ? rates_total - prev_calculated + 1 : rates_total;
That is the correct code for how many bars to copy (including the current, still opened, bar)
I'm sorry, I don't mean to go against your ideas, your experience is much greater than mine.
However, your code fix is not entirely correct in my context.
It would work if I wanted the values to be updated every tick, which is not my intention, as specified in my code
// --- With this code, the average (plot) is only updated when a new bar is opened if ( prev_calculated < rates_total)
On the other hand, indeed, if we remove the 'new bar' condition, your code is fully functional.
And there, indeed, it is necessary to add +1 has prev_calculated to have good execution.
But again, it was not my desire to make this update every tick.
My intention was to only update the indicator when a new bar is opened, hence my initial choice of code.
//if( prev_calculated < rates_total) //{ // --- Optimization to only take into account the new bar //i_Diff = rates_total - prev_calculated; i_Diff = (prev_calculated > 0 ) ? rates_total - prev_calculated + 1 : rates_total; //}In my choice, i_Diff = rates_total - prev_calculated works great, including on new bars after initial run.
I'm sorry, I don't mean to go against your ideas, your experience is much greater than mine.
However, your code fix is not entirely correct in my context.
It would work if I wanted the values to be updated every tick, which is not my intention, as specified in my code
On the other hand, indeed, if we remove the 'new bar' condition, your code is fully functional.
And there, indeed, it is necessary to add +1 has prev_calculated to have good execution.
But again, it was not my desire to make this update every tick.
My intention was to only update the indicator when a new bar is opened, hence my initial choice of code.
In my choice, i_Diff = rates_total - prev_calculated works great, including on new bars after initial run.Do whatever you want to do. But the way you wrote that code you have an error that is going to show wrong values for each bar formed after the initial run (that is going to be a classical case of repainting)
all the best
I'm too angry to answer you calmly, but the subject remains open. Would come back
You are "too angry to answer calmly"? 😀😀😀
- Your initial run values are drawn using states "at the close" of the bar
- Then all of a sudden you update values only "on open of a new" bar
- And then, on each time frame or symbol change, those "on open of a new bar" values are miraculously going to disappear and they are all going to become "at the close" again
Save your self and all of us time and correct your code(s) to be consistent in all usage conditions - otherwise it falls into a basic definition of repainting indicator(s)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
CCI beginner tutorial by William210:
Beginner tutorial on CCI to learn to code in MQL5
Author: Gerard Willia G J B M Dinh Sy