is something wrong with the kama already posted here: https://www.mql5.com/en/code/9167 or do you want to reinvent the wheel?
//z
is something wrong with the kama already posted here: https://www.mql5.com/en/code/9167 or do you want to reinvent the wheel?
//z
What's wrong with reinventing the wheel?
You are correct that I do appear to be doing this, the reason being that in Kaufman's original example, he goes on to further calculations for buy and sell signals. I am trying to work through the various stages so that I can incorporate this into the indicator as I want to add it to my weekly charts and use it as a trend filter on the daily charts.
Thank you Zzuegg for the link - I'll try and figure out how it works (still struggling with MQL4!) so that I can adapt it to my needs.
Cheers
What's wrong with reinventing the wheel?
You are correct that I do appear to be doing this, the reason being that in Kaufman's original example, he goes on to further calculations for buy and sell signals. I am trying to work through the various stages so that I can incorporate this into the indicator as I want to add it to my weekly charts and use it as a trend filter on the daily charts.
Thank you Zzuegg for the link - I'll try and figure out how it works (still struggling with MQL4!) so that I can adapt it to my needs.
Cheers
Still struggling to understand Bars and loop counting. Here is a snippet of the momentum code:
int start() { int i,counted_bars=IndicatorCounted(); //---- if(Bars<=MomPeriod) return(0); //---- initial zero if(counted_bars<1) for(i=1;i<=MomPeriod;i++) MomBuffer[Bars-i]=0.0; //---- i=Bars-MomPeriod-1; //Print("bars =",Bars); //Print("i = ",i); //Print("count = ",counted_bars); if(counted_bars>=MomPeriod) i=Bars-counted_bars-1; //Print("i = ",i); while(i>=0) { MomBuffer[i]=Close[i]-Close[i+MomPeriod]; i--; } return(0); }
Could somebody please clarify this for for me, is: i=Bars-MomPeriod-1; the first value of the while loop counter?
At the end of the first cycle this value is reduced by 1?
Does this continue until the: if(counted_bars>=MomPeriod) i=Bars-counted_bars-1; is true - because "i" will be set to zero if true?
Cheers

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am trying to develop an adaptive moving average indicator based on Perry Kaufman's method. So far, I have modelled the indicator in excel and I am now trying to code it in MQL4. I haven't gotten very far and could do with some help if anyone would be kind enough?
Here is my code to date:
I have adapted the custom momentum indicator to calculate the momentum over a 10 day period along with some of the other variable values. What I need to do next is calculate the absolute 1 day differences in value during the 10 day period then add these up to calculate the 10 day difference. Here is how I do this with excel:
In order to achieve this, I think that I need to use a variation of the momentum calculation to calculate the 1 day difference then, collect these in an array?? This is where I could really do with some help or ideas - how do I do this with MQL4?
Thanks in advance