I think the missing break is not an error. It is done intentionally to add the values for higher timeframes as well by continuing down to the following cases.
But I think there is another error. After each call to iMA(), k is updated using '+=' operator. I think it should be '*='. As the higher timeframe should be calculated by multiplying the current time frame by a number. So if the current timeframe is H4, k should change as k *= 6 to calculate D1 from it. Also for case 1440: the multiplier should be 5 (not 4) as there are 5 daily bars in a week.
In my opinion, the algorithm of the indicator is right, nothing to be changed. The smaller the timeframe, the more bars that are used on the calculation, what makes sense to me.
I would have done it other way, using "break" on the switch statements, and modifying the period depending on the current timeframe the number of bars, to avoid calling so many times iMA() when using small timeframes for each bar. But anyway, it works the way it is.
I have modified the code to cope with the new MQL4. But indicator values are exactly the same as on the original CCFp.mq4.
List of changes:
Adapted original CCFp.mq4 to new MQL4
Minor changes to improve speed and clarity (renaming)
Added zero line level to the indicator
Once indicator is loaded, as a default, each time a tick arrives, only the last 2 candles are recalculated.
I have left the copyright values to the original author, and change the link to this article on mql5.com.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I think the missing break is not an error. It is done intentionally to add the values for higher timeframes as well by continuing down to the following cases.
But I think there is another error. After each call to iMA(), k is updated using '+=' operator. I think it should be '*='. As the higher timeframe should be calculated by multiplying the current time frame by a number. So if the current timeframe is H4, k should change as k *= 6 to calculate D1 from it. Also for case 1440: the multiplier should be 5 (not 4) as there are 5 daily bars in a week.
In my opinion, the algorithm of the indicator is right, nothing to be changed. The smaller the timeframe, the more bars that are used on the calculation, what makes sense to me.
I would have done it other way, using "break" on the switch statements, and modifying the period depending on the current timeframe the number of bars, to avoid calling so many times iMA() when using small timeframes for each bar. But anyway, it works the way it is.
I have modified the code to cope with the new MQL4. But indicator values are exactly the same as on the original CCFp.mq4.
List of changes:
I have left the copyright values to the original author, and change the link to this article on mql5.com.
Hi it seems the author has removed the links to download the indicators. I can't find them in the OP.
It's in the first post. Links are underlined.
This will take you to the relevant page