- 05 Aug 2017, 11:34
#1629
Xande wrote: ↑30 Jul 2017, 22:53 Geko, can you please verify what CCFp calculation are you using for the MA? There seems to be a bug based on this post -> https://www.mql5.com/en/code/9088I will get back to you later on this Summer break no coding for the momentCode: Select allCorrect code should bedouble ma(string sym, int per, int Mode, int Price, int i) { double res = 0; int k = 1; int ma_shift = 0; int tf = 0; switch(Period()) { case 1: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); k += 5; case 5: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); k += 3; case 15: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); k += 2; case 30: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); k += 2; case 60: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); k += 4; case 240: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); k += 6; case 1440: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); k += 4; case 10080: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); k +=4; case 43200: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); } return(res); }
Code: Select alldouble ma(string sym, int per, int Mode, int Price, int i) { double res = 0; int k = 1; int ma_shift = 0; int tf = 0; switch(Period()) { case 1: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); k *= 5; case 5: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); k *= 3; case 15: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); k *= 2; case 30: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); k *= 2; case 60: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); k *= 4; case 240: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); k *= 6; case 1440: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); k *= 5; case 10080: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); k *=4; case 43200: res += iMA(sym, tf, per*k, ma_shift, Mode, Price, i); } return(res); }
Cheers,
G
G