# IndicatorCounted()函数有什么用

MetaQuotes ID是什么？从文章中找出 答案！
14
2008.02.24 12:06

int start()
{ Print("Bars is ",Bars);
if(Bars<=MA_Period) return(0);
ExtCountedBars=IndicatorCounted(); Print("ExtCountedBars",ExtCountedBars);
if (ExtCountedBars<0) return(-1);
if (ExtCountedBars>0) ExtCountedBars--;
sma();
return(0);
}

10:40:39 112 inputs: MA_Period=13; MA_Shift=0; MA_Method=0;
10:40:39 2008.01.15 00:00 112 GBPUSD,M5: Bars is 1001
10:40:39 2008.01.15 00:00 112 GBPUSD,M5: ExtCountedBars-1

11560
2008.02.25 10:25
Attach this sample indicator CheckIndicatorCounted.mq4 to any chart and investigate the log (Print() fuction)
```//+------------------------------------------------------------------+
//|                                        CheckIndicatorCounted.mq4 |
//|                                        http://www.metaquotes.net/ru/ |
//+------------------------------------------------------------------+

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
int    counted_bars=IndicatorCounted();
//----
Print(TimeToStr(TimeCurrent()),"    Bars=",Bars,"  Indicatorcounted=",counted_bars);
//----
return(0);
}
//+------------------------------------------------------------------+```
14
2008.02.25 12:50

/