if(counted_bars>0) counted_bars--;的作用?

 
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;

这是MACD自定义指标代码中一段,我大致理解这段代码的意思,但是有一点不清楚的地方就是:

if(counted_bars>0) counted_bars--;

这句话似乎没有必要啊,我注释了这句话,MACD似乎也运行的很好。

我是新手,请高手解释一下,谢谢!

 
节省系统资源的 写法 减少不必要的运算 提升工作效率
 
keyila:
节省系统资源的 写法 减少不必要的运算 提升工作效率


我知道这点。我的疑问是

if(counted_bars>0) counted_bars--;

这句话似乎是没有必要的,这句话有什么作用呢?

就算没有这句话 ,还是会计算正确的。

原因: