Problem with indicator in "Current State"

 
currentPrice=iClose(NULL,PERIOD_CURRENT,i);
prevPrice=iClose(NULL,PERIOD_CURRENT,i+1);

Aren't these unnecessary?

if(i<limit-bars_back)

The first calculation will be executed, but the second and subsequent calculations will not be executed because "limit-bars_back" will be negative.

In other words, the total is always zero.

if(counted_bars>0)
      counted_bars--;
   int limit=Bars-counted_bars;

If the starting position of the calculation is not taken into account, an error will occur.

The checks a trading robot must pass before publication in the Market
The checks a trading robot must pass before publication in the Market
  • www.mql5.com
Before any product is published in the Market, it must undergo compulsory preliminary checks in order to ensure a uniform quality standard. This article considers the most frequent errors made by developers in their technical indicators and trading robots. An also shows how to self-test a product before sending it to the Market.