NN China
Posts: 1 since Oct 2016
Thanks Given: 0
Thanks Received: 0
|
hello ! traders , here is the program (code from MQL4):
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 LimeGreen
extern int Ha = 61;
double Avg[];
int init() {
IndicatorBuffers(1);
Ha = MathMax(Ha, 1);
SetIndexBuffer(0, Avg);
SetIndexDrawBegin(0, Ha);
return (0);
}
int start() {
int C;
double N1;
double N2;
// main code
int Li_0 = IndicatorCounted();
if (Li_0 < 0) return (-1);
if (Li_0 > 0) Li_0--;
int ak = MathMin(Bars - 1, Bars - Li_0 + Ha);
for (int i = ak; i >= 0; i--) {
N1 = (Ha + 1) * iMA(NULL, 0, 1, 0, MODE_SMA, PRICE_CLOSE, i);
N2 = Ha + 1;
C = 1;
for (int j = Ha; C <= Ha; j--) {
N1 += j * iMA(NULL, 0, 1, 0, MODE_SMA, PRICE_CLOSE, i + C);
N2 += j;
if (C <= i) {
N1 += j * iMA(NULL, 0, 1, 0, MODE_SMA, PRICE_CLOSE, i - C);
N2 += j;
}
C++;
}
Avg[i] = N1 / N2; //output the line
}
return (0);
}
you see. there are two loops inside and keep calculating [iMA....].for the second one it likely never stop....so how to translate this into Multicharts ? (if i replace the C<= Ha to j >=0 ?) thx !
thx
|