If you say you're having an error, you should also quote the error description.
In case, as I suppose, the error is "undeclared identifier" and the index variable wasn't declared before, then
for (int index=nCountedBars + NB -1, int ptr =0 ;index >= nCountedBars ; index--, ptr++) flow[ptr] = (High[index] + Low[index]) / 2;
should do the trick.
Of course there may be other issues, as from this code example we can't know the values of nCountedBars and NB at the given time and e.g. if the flow[] array was declared correctly, so if you have any further problems, please tell us what exactly the error message is saying.
sorry :
'=' - unexpected token... -> int ptr =0 'ptr' - undeclared identifier -> ptr++)
This is the total code
#property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Silver #property indicator_width1 2 extern int NB = 5; extern int DEBUG = 1; int LITE = 1; //---- input parameters #define TREND_DIFF_POSITIVE 0 #define NO_TREND_DIFF_POSITIVE 1 #define SPEARMAN_TREND_POSITIVE 0 #define SPEARMAN_TREND_NEGATIVE 1 #define SPEARMAN_NO_TREND 2 #define KENDALL_TREND_POSITIVE 0 #define KENDALL_TREND_NEGATIVE 1 #define KENDALL_NO_TREND 2 //---- buffers double flow[40]; int handle; // double flow[40] = {44.3, 21.3, 31.4, 8.7, 12.8, 45.0, 88.1, 32.0, // 52.3, 30.3, 95.8, 50.4, 71.6, 26.7, 3.8, 36, 46, 34.3, 77.2, 55.3, // 64.2, 85.5, 18.6, 50.9, 93.6, 26.8, 59, 99.1, 57, 78.1}; double FsortedFlow[40]; double IsortedFlow[40]; double final[] ; double final1[] ; double final2[] ; double final3[] ; int RowNum = 0; int LastTrend = -1; int UP_IND = 1; int DOWN_IND = 0; int ThePeriod = 15; int offset = 3; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { SetIndexBuffer(0,final); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexEmptyValue(0,0.0); SetIndexLabel(0,"TOTAL"); //---- initialization done if (DEBUG == 1 || LITE == 1) { handle=FileOpen("output.txt",FILE_CSV|FILE_WRITE,';'); if(handle<1) { Print("File output.txt not found, the last error is ", GetLastError()); return(false); } } return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { if (DEBUG == 1 || LITE == 1) FileClose (handle); //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int nCountedBars, limit, index, k , A, B; nCountedBars=IndicatorCounted(); //---- check for possible errors if (nCountedBars<0) return(-1); //---- last counted bar will be recounted if (nCountedBars > 0) nCountedBars-= (NB - 3) ; // Current for (index=nCountedBars + NB -1, int ptr =0 ;index >= nCountedBars ; index--, ptr++) flow[ptr] = (High[index] + Low[index]) / 2; for (index=nCountedBars + NB - 1; index<Bars ; index++) { if (index != nCountedBars + NB - 1) moveQueue (NB); flow [0] = (High[index] + Low[index]) / 2; double T = NB; double average = (T - 1)/ 2; double variance = (T + 1) / 12; double tol_less_average = average - (1.96 * MathSqrt(variance)); double tol_plus_average = average + (1.96 * MathSqrt(variance)); double tmp = Dpositive (T ); double status_Dpos = report_dPos (tol_less_average, tol_plus_average, tmp); if (DEBUG == 1) FileWrite (handle, "TEST1: average ", average, " variance ",variance," tol_less_average ", tol_less_average, " tol_plus_average ", tol_plus_average, " tmp ", tmp, " status_Dpos ", status_Dpos) ; if (status_Dpos == TREND_DIFF_POSITIVE) { A = 2; B = 1; } else { A = 1; B = -1; } if (DEBUG == 1) FileWrite (handle,"TEST1: A: ", A, " B ", B); // TEST2 ArrayCopy (FsortedFlow, flow, 0, 0, WHOLE_ARRAY); ArraySort (FsortedFlow, NB, 0, MODE_ASCEND); getVt (NB); double sigmaDt = getDtSquared (NB); double ro = 1 - (( 6.00 / (NB * ((NB*NB) - 1.00))) * sigmaDt) ; double VarianceRo = 1.00 / ( NB -1); double tol_less_spearman = (-1.96 * MathSqrt(VarianceRo)); double tol_plus_spearman = (1.96 * MathSqrt(VarianceRo)); double status_spearman = report_spearman (tol_less_spearman, tol_plus_spearman, ro ); double VCRSpearman = ro / MathSqrt(VarianceRo); if (DEBUG == 1) FileWrite (handle,"TEST2: sigmaDt ", sigmaDt, " ro ", ro, " VarianceRo ", VarianceRo, " tol_less_spearman ", tol_less_spearman, " tol_plus_spearman ", tol_plus_spearman, " status_spearman ", status_spearman , " VCRSpearman ", VCRSpearman); if (status_spearman == SPEARMAN_TREND_POSITIVE) { B = B + A; if (VCRSpearman > 1.96) { B = B + A; } } else if (status_spearman == SPEARMAN_TREND_NEGATIVE) { B = B - A; if (VCRSpearman > 1.96) { B = B - A; } } if (DEBUG == 1) FileWrite (handle, "TEST2: A: ", A, " B ", B); // TEST3 int P = 0; int Q = 0; for (k=1; k< NB ; k++) { P += recursP(k, NB); Q += recursQ(k, NB); } int S = P - Q; double tao = (2.00 * S) / (NB * (NB -1.00)); double varianceTao = (2.00 * ((NB * 2.00) + 5.00)) / (( 9.00 * NB) * ( NB - 1.00)); double tol_less_kendall = (-1.96 * MathSqrt(varianceTao)); double tol_plus_kendall = (1.96 * MathSqrt(varianceTao)); double status_kendall = report_kendall (tol_less_kendall, tol_plus_kendall, tao ); double VCRKendall = tao / MathSqrt(varianceTao); if (DEBUG == 1) FileWrite (handle, "TEST3: tao: ", tao, " tol_plus_kendall ", tol_plus_kendall, " tol_less_kendall ", tol_less_kendall); double theTao; if (tao > tol_plus_kendall) theTao = tao - tol_plus_kendall; else if (tao < tol_less_kendall) theTao = tao - tol_less_kendall; else theTao = 0; if (status_kendall == KENDALL_TREND_POSITIVE) { B = B + A; if (VCRKendall > 1.96) { B = B + A; } } else if (status_kendall == KENDALL_TREND_NEGATIVE) { B = B - A; if (VCRKendall > 1.96) { B = B - A; } } final [index - NB + 1] = B; // if (DEBUG ==1) FileWrite (handle, "TEST3: A: ", A, " B ", B); // if (LITE == 1) FileWrite (handle, "i = ", index, " - ", final[index]); } return (0); } double Dpositive (double number) { int i ; double Dpos = 0; for (i=0; i< number -1 ; i++) { if (flow[i + 1] > flow[i]) Dpos++; if (DEBUG == 1) FileWrite (handle, " flow+ ", flow[i + 1], " flowCurrent ", flow[i], " Dpos ", Dpos); } return (Dpos); } int report_dPos (double less, double plus, double value) { if (value >= less && value <= plus) return (NO_TREND_DIFF_POSITIVE); return (TREND_DIFF_POSITIVE); } int report_spearman (double less, double plus, double value ) { if (value >= less && value <= plus) return (SPEARMAN_NO_TREND); else if (value > 0) return (SPEARMAN_TREND_POSITIVE); else return (SPEARMAN_TREND_NEGATIVE); } int report_kendall (double less, double plus, double value ) { if (value >= less && value <= plus) return (KENDALL_NO_TREND); else if (value > 0) return (KENDALL_TREND_POSITIVE); else return (KENDALL_TREND_NEGATIVE); } void getVt (int nb) { int i, j; for (i=0; i< nb ; i++) { for (j=0;j< nb ;j++) { if (flow[i] == FsortedFlow[j]) { IsortedFlow[i] = j + 1; break; } } } } int getDtSquared (int nb) { int i, val, res; res = 0; for (i=0;i< nb;i++) { val = MathAbs((i+1) - IsortedFlow[i]); // if (DEBUG == 1) FileWrite (handle,i+1, " - ", IsortedFlow[i]); // if (DEBUG == 1) FileWrite (handle, "val : ", val); val *=val; res+=val; } return (res); } int recursP(int from, int to) { int i, res = 0 ; for (i=from; i< to; i++) if (IsortedFlow[i] > IsortedFlow[from -1]) res++; return (res); } int recursQ(int from, int to) { int i, res = 0 ; for (i=from; i< to; i++) if (IsortedFlow[i] < IsortedFlow[from -1]) res++; return (res); } void moveQueue (int nb) { int i; for (i = NB ; i > 0 ; i -- ) flow[i] = flow[i - 1]; }
This is the total code
Okay, I see.. this looks like MQL4 code --> should probably be moved to the MT4 section
[and sorry, I can only help with MQL5]
sorry :
This is the total code
If a paid coder provided you such code recently you should use an other one. It's old and obsolete syntax (since 2014 !).
It probably doesn't compile any more since the last update to 1220.
I fixed it for you, don't know why I did it
Thank you !
If you don't know why you did it chnage histogram to line and arrays size (more than 40) and try with a 50 NB period or higher... maybe you will feel like you have not lost your time ;
I think we need to find an indicator to refine but it can be a good start

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello.
There'a a few years i paid a freelancer to build an indicator. It worked fine but now, i try to compile it and i have an error on this line :
Can you help me please ?