Indicator not plotting!
How comes the problem is from the function if the function is filling the array correctly as you can see from the screenshot? this print is after executing the function.
And I am not using CopyBuffer. Should I?
I am filling the buffer array like this:
//+------------------------------------------------------------------+ //| FUNCTION: Process Timeframes | //+------------------------------------------------------------------+ void ProcessTimeframe(ENUM_TF tf_enum, double &buffer[], int rates_total) { if(tf_enum == DISABLED) return; // Do not process if it's DISABLED Print("Identifying similar closes between current Timeframe and ", EnumToString(tf_enum)); ENUM_TIMEFRAMES tf = ENUMToTimeframe(tf_enum); int tfLookback = (Lookback * PeriodSeconds(PERIOD_CURRENT) / PeriodSeconds(tf)) + 1; datetime TimeArray[]; ArrayResize(TimeArray, tfLookback); ArraySetAsSeries(TimeArray, true); double CloseArray[]; ArrayResize(CloseArray, tfLookback); ArraySetAsSeries(CloseArray, true); CopyTime(_Symbol, tf, 0, tfLookback, TimeArray); CopyClose(_Symbol, tf, 0, tfLookback, CloseArray); Print("Current TimeArray Values:"); ArrayPrint(TimeArray); Print("Current CloseArray Values:"); ArrayPrint(CloseArray); for(int i=0; i<rates_total && i<Lookback; i++) { datetime currentBarTime = iTime(_Symbol, 0, i); bool found = false; // added to track if we found a valid value for(int j=0; j<tfLookback; j++) { if(TimeArray[j] == currentBarTime) { buffer[i] = CloseArray[j]; found = true; break; } } if(!found) // if we didn't find a valid value, set buffer to EMPTY_VALUE { buffer[i] = EMPTY_VALUE; } } Print("Current ", EnumToString(tf_enum), " Buffer values:"); ArrayPrint(buffer); }
What I noticed too, when printing the array, all values of the array after my "lookback" period are filled with 0.00000 which seems to be the initialized value when I defined the array. the arrayprint function shows about 100.000 positions in the array, I don't know if this is normal?
No copybuffer isn't needed now that I see what you have in the function...these numbers like "2E+308" are too large beyond the visible range of the window. I don't really understand what the indicator is supposed to do so I can't provide much help
Edit: For starters, try changing the for loop in your function to this:
for(int i=0; i<rates_total && i<Lookback; i++) { bool found = false; // added to track if we found a valid value if(TimeArray[i] == time[i]) { buffer[i] = close[i]; found = true; break; } if(!found) // if we didn't find a valid value, set buffer to EMPTY_VALUE buffer[i] = EMPTY_VALUE; } }
the timeframe checking code has to different/may not be necessary
the PERIOD_CURRENT constant isn't actually a time based period like PERIOD_M15, it is only used in certain instances, you may have to try something else
ENUM_TIMEFRAMES tf = ENUMToTimeframe(tf_enum); int tfLookback = (Lookback * PeriodSeconds(ChartPeriod(0)/ PeriodSeconds(tf)) + 1;
This assumes every bar every exists — they don't. What if there are no ticks during a specific candle period? There can be minutes between ticks during the Asian session, think M1 chart. Larger charts, think weekend, market holiday (country and broker specific), requires knowledge of when your broker stops and starts (not necessary the same as the market.)
"Free-of-Holes" Charts - MQL4 Articles (2006)
No candle if open = close ? - MQL4 programming forum (2010)
Use iBarShift.
thank you very much for your suggestions. the problem was simply that it was assigning the values beginning from position 0 of the buffer, whereas the buffer is not really a timeseries as described in the documentation, it begins from the oldest bar to the newest one!
That's true, you could start your loop from "prev_calculated" instead of starting the loop from zero
This assumes every bar every exists — they don't. What if there are no ticks during a specific candle period? There can be minutes between ticks during the Asian session, think M1 chart. Larger charts, think weekend, market holiday (country and broker specific), requires knowledge of when your broker stops and starts (not necessary the same as the market.)
"Free-of-Holes" Charts - MQL4 Articles (2006)
No candle if open = close ? - MQL4 programming forum (2010)
Use iBarShift.
oh :-) that's very interesting. thank you william!

- Free trading apps
- Free Forex VPS for 24 hours
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hey guys, I wrote a simple indicator that plots "Sections" on the chart. i checked that the buffer arrays are filled correctly, but it is still not plotting the lines.
I tried everything, and now simplified the code as simple as possible, still not plotting:
My BufferArrays are filled as follows:
Any advise why it is still not plotting?