It's going to be quicker for someone to modify the MQL4 code than to port the MQL5 code to MQL4 . . . probably.
- You could SEARCH for kama+mql4, get the indicator, and call iCustom.
int init(){ OnInitKama(); : } //+------------------------------------------------------------------+ //| Perry Kaufman's Adaptive Moving Average | //+------------------------------------------------------------------+ #define FASTEST_PERIOD 2 #define SLOWEST_PERIOD 99 #define LOOKBACK 10 double kama.High.value, kama.Low.value, fastestAlpha, slowestAlpha; int KamaCounted; void OnInitKama(){ KamaCounted = 0; fastestAlpha = 2. / (FASTEST_PERIOD + 1), slowestAlpha = 2. / (SLOWEST_PERIOD + 1); } void KamaUpdate(){ int iKama = Bars - 1 - KamaCounted; if (KamaCounted == 0){ iKama = Bars - 1 - LOOKBACK; kama.High.value = High[iKama]; kama.Low.value = Low[iKama]; } for(; iKama > 0; iKama--) KamaUpdatePrice(kama.High.value, High, iKama) KamaUpdatePrice(kama.Low.value, Low, iKama) } KamaCounted = Bars - 1; // Haven't done bar zero } void KamaUpdatePrice(double& value, double price[], int iBar){ int iLimit = iBar + LOOKBACK; double noise=0.00000001, signal = MathAbs( price[iLimit] - price[iBar] ); for (; iLimit > iBar; iLimit--){ noise += MathAbs( price[iLimit] - price[iLimit-1] ); } double alpha = signal/noise * (fastestAlpha - slowestAlpha) + slowestAlpha; kama.value += alpha * (price[iBar] - kama.value); } int start(){ KamaUpdate(); }
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
IF you see in MT5 you could find this indicator. I have attached it here.
There are similar ones in MT4. My problem is that I want to apply it to "Low" or "High" not only to close. You could do this in MT5, But because my broker is using MT4 I need to do it in this platform.
Can Anybody help?
I appreciate your time,
Regards,