Alright so I have been working on creating this indior that's very much like fractals and it appears to draw all the arrows properly as it goes trough the chart the first time but as soon as it pulls new ones the rankings of the arrows are mistaken.

I absolutely have no clue what I am doing wrong so any help would be appreciated.
I feel like it should have something to do with the previous arrow position but that I would not know what is wrong with it even if it's really that or not.

Inserted Code //p ------------------------------------------------------------------ //| FractalsExercise.mq4 | //| | //| https://www.mql5.com | //p ------------------------------------------------------------------ #property copyright #property Hyperlink https://www.mql5.com #property version 1.00 #property strict #property indior_chart_window #property indior_buffers 2 double Highs#91;#93;; double Lows#91;#93;; double Stored = 0; int LastArrow = 0; //1 = high -- 2 = Reduced int LastArrowPosition = 0; // ------------------------------------------------------------------ //| Custom indior initialization serve | // ------------------------------------------------------------------ int OnInit() //-- drawing fashion SetIndexStyle(0, DRAW_ARROW, EMPTY, 1, clrGreen); SetIndexArrow(0, 226); SetIndexStyle(1, DRAW_ARROW, EMPTY, 1, clrRed); SetIndexArrow(1, 225); //-- indior buffers SetIndexBuffer(0, Highs); SetIndexBuffer(1, Lows); //-- return(INIT_SUCCEEDED); // ------------------------------------------------------------------ //| Custom indior iteration serve | // ------------------------------------------------------------------ int OnCalculate(const int rates_total, const int prev_calculated, const datetime time#91;#93;, const double open#91;#93;, const double top #91;#93;, const double low#91;#93;, const double shut #91;#93;, const long tick_volume#91;#93;, const long volume#91;#93;, const int spread#91;#93;-RRB- //-- int limit = rates_total - prev_calculated - 2; limit = limit lt; 1 )? 2: limit; for(int I = restrict; I gt; 1; I--) //Loop from rear to front if(rates_total gt; prev_calculated) //Assessing new closed candles if(Top #91;t #93; gt;= High#91;I 1#93; Top #91;I#93; gt;= High#91;I - 1#93; Low Cost #91;I#93; lt;= Low#91;I 1#93; Low Cost #91;I#93; lt;= Low#91;I - 1#93;-RRB- //Assessing double arrows Printing (--DOUBLE ARROW IGNORED--, I); else if(Top #91;I#93; gt;= High#91;I 1#93; Top #91;I#93; gt;= High#91;I - 1#93;-RRB- //Assessing highs LastArrow == 0) //Is last arrow a non Lows#91;LastArrowPosition#93; = Stored; //Draws arrow LastArrow = 1; //Last arrow = large Stored = High#91;I#93;; LastArrowPosition = I; else if(LastArrow == 1) //Is last arrow a top if(Stored lt; Top #91;I#93;-RRB- Stored = High#91;I#93;; LastArrowPosition = I; else if(Stored gt;= High#91;I#93;-RRB- Stored = Stored; LastArrowPosition = LastArrowPosition; else if(Low#91;I#93; lt;= Reduced #91;I 1#93; Low Cost #91;I#93; lt;= Low#91;I - 1#93;-RRB- //Assessing lows //-- return value of prev_calculated for second call return(rates_total); // ------------------------------------------------------------------

Any help would be appreciated.
Thanks!