accurate indicator, need modify.

 
this indicator repaint, i edit i=1 but not showing line.
Files:
 

it is accurate because it repaints. It repaints because you are counting up. Always count down.

 
WHRoeder:

it is accurate because it repaints. It repaints because you are counting up. Always count down.


i didn't got u master please explain me further.
 
ansimuskan:
i didn't got u master please explain me further.

What WHRoeder ment is that the bar iteration should be from past to present, and not the other way around. If not, your accurate indicator "sees the future". Should be like this:

int start()
{
   // Start, limit, etc..
   int start = 0;
   int limit;
   int counted_bars = IndicatorCounted();
   
   // nothing else to do?
   if(counted_bars < 0) 
       return(-1);

   // do not check repeated bars
   limit = Bars - 1 - counted_bars;
   
   // Iteration from past to present
   for(int pos = limit; pos >= start; pos--)
   {  
       // Blabla
   }
}
 
flaab:

What WHRoeder ment is that the bar iteration should be from past to present, and not the other way around. If not, your accurate indicator "sees the future". Should be like this:

Flaab master there is no word such as iteration in code
 
ansimuskan:
Flaab master there is no word such as iteration in code

LOL . . . let me help . . iteration

Run this script . . .

//+------------------------------------------------------------------+
//|                                                    iteration.mq4 |
//|                      Copyright © 2012, MetaQuotes Software Corp. |
//|                                        https://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, MetaQuotes Software Corp."
#property link      "https://www.metaquotes.net"

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
   {
   int iteration=0;
   
   while(iteration < 10)
      {
      iteration++;
      Print("Iteration number ", iteration);
      }
      
   Print("All 10 iterations finished . . .  thank you.");
   return(0);
   }
//+------------------------------------------------------------------+
Reason: