Hi everyone, I am having an issue with some code which compiles and can be run however the array indexes are not giving me the numbers I want. To put it simply I am trying to loop back through the chart bars anad find highs and lows based on "BarsN" to the left and right and then store the highs and lows in an array. When I go back to call the array and ask for index 0 and index 1 the numebrs I am getting do not match the objects I have created on the chart. Here is the ontick function, I have placed "*****" after the lines that I seem to be having the issue with. Basically I want it to look back from time current to the first low/high and then again to the 2nd low/high and work out if a trend is forming... Any help would be appreciated - Thanks. int bars = iBars(_Symbol, PERIOD_CURRENT); if (totalBars != bars) { totalBars = bars; Comment("DownTrend: ",isDownTrend, "\nUpTrend: ",isUpTrend); // Remove previous objects (if any) for (int i = 0; i < currentIndex; i++) { ObjectsDeleteAll(0,"HighCircle"); ObjectsDeleteAll(0,"LowCircle"); } for (int i = 0; i < iBars(_Symbol, PERIOD_CURRENT); i++) { if (i > BarsN && iHighest(_Symbol, HIGHLOWTRIGGERTIMEFRAME, MODE_HIGH, BarsN*2+1, i-BarsN) == i) { double high = iHigh(_Symbol, HIGHLOWTRIGGERTIMEFRAME, i); string objectName = "HighCircle" + IntegerToString(i); ObjectCreate(0, objectName, OBJ_ARROW_UP, 0, iTime(_Symbol, PERIOD_CURRENT, i), high); ObjectSetInteger(0, objectName, OBJPROP_COLOR, clrRoyalBlue); ObjectSetInteger(0, objectName, OBJPROP_FILL, clrRoyalBlue); // Store the high price in the array highObjectPrices[currentIndex] = high; currentIndex++; // Reset the index if it exceeds 4 (since you want to store 5 highs and 5 lows) if (currentIndex >= ArrSize) { currentIndex = 0; } } if (i > BarsN && iLowest(_Symbol, HIGHLOWTRIGGERTIMEFRAME, MODE_LOW, BarsN*2+1, i-BarsN) == i) { double low = iLow(_Symbol, HIGHLOWTRIGGERTIMEFRAME, i); string objectName = "LowCircle" + IntegerToString(i);