convert to MQL5 , find the error New comment Alexander P. 2023.03.16 20:12 Hello, I'm trying to convert this pine script to MQL5. but I can't find the error can someone help me? // Pinscript C_BodyHi = math.max(close, open) C_BodyLo = math.min(close, open) C_Body = C_BodyHi - C_BodyLo pine_ema(src, length) => alpha = 2 / (length + 1 ) sum = 0.0 sum := na(sum[ 1 ]) ? src : alpha * src + ( 1 - alpha) * nz(sum[ 1 ]) C_BodyAvg = pine_ema(C_Body, 14 ) Here is my conversion to MQL5 that doesn't work: double pine_ema( double src[], int length) { double alpha = 2.0 / (length + 1 ); double sum[]; ArraySetAsSeries (sum, true ); ArrayResize (sum, ArraySize (src)); for ( int i = 1 ; i < ArraySize (src); i++) { if (i == 1 || IsNaN(sum[i- 1 ])) sum[i] = src[i]; else sum[i] = alpha * src[i] + ( 1 - alpha) * sum[i- 1 ]; } return (sum[ ArraySize (sum)- 1 ]); } double C_BodyHi = MathMax (close, open); double C_BodyLo = MathMin (close, open); double C_Body = C_BodyHi - C_BodyLo; double C_BodyAvg = pine_ema(ArrayCopySeries(C_Body), 14 ); New comment
Hello,
I'm trying to convert this pine script to MQL5. but I can't find the error can someone help me?
Here is my conversion to MQL5 that doesn't work: