Average True Range ATR Indicator For MT5
Table Of Contents:
- Average True Range ATR Indicator For MT5
- 安装Average True Range ATR Indicator For MT5
- Average True Range ATR Indicator For MT5参数
- Average True Range ATR Indicator For MT5缓冲区
- 守则主要部分
Average True Range ATR Indicator For MT5的Average True Range ATR Indicator For MT5是几乎每个交易平台中非常著名的标准指标之一。它用作许多其他指标的基础,这些指标使用其值作为进一步计算的输入。 ATR指标计算最近X支蜡烛的平均大小。这些值使您可以看到市场波动的增加或减少。
安装Average True Range ATR Indicator For MT5
通过上面的表格下载指标后,您需要解压缩zip文件。然后,您需要将文件atr.mq5复制到MT5安装的文件夹MQL5Indicators中。之后,请重启MT5,然后您将能够在指标列表中看到该指标。
Average True Range ATR Indicator For MT5参数
Average True Range ATR Indicator For MT5具有要配置的1 参数。
input int InpAtrPeriod=14; // ATR period
Average True Range ATR Indicator For MT5缓冲区
Average True Range ATR Indicator For MT5提供2 缓冲区。
SetIndexBuffer(0,ExtATRBuffer,INDICATOR_DATA); SetIndexBuffer(1,ExtTRBuffer,INDICATOR_CALCULATIONS);
守则主要部分
int OnCalculate(const int rates_total, const int prev_calculated, const datetime &Time[], const double &Open[], const double &High[], const double &Low[], const double &Close[], const long &TickVolume[], const long &Volume[], const int &Spread[]) { int i,limit; //--- check for bars count if(rates_total lt =ExtPeriodATR) return(0); // not enough bars for calculation //--- preliminary calculations if(prev_calculated==0) { ExtTRBuffer[0]=0.0; ExtATRBuffer[0]=0.0; //--- filling out the array of True Range values for each period for(i=1;i lt rates_total && !IsStopped();i++) ExtTRBuffer[i]=MathMax(High[i],Close[i-1])-MathMin(Low[i],Close[i-1]); //--- first AtrPeriod values of the indicator are not calculated double firstValue=0.0; for(i=1;i lt =ExtPeriodATR;i++) { ExtATRBuffer[i]=0.0; firstValue+=ExtTRBuffer[i]; } //--- calculating the first value of the indicator firstValue/=ExtPeriodATR; ExtATRBuffer[ExtPeriodATR]=firstValue; limit=ExtPeriodATR+1; } else limit=prev_calculated-1; //--- the main loop of calculations for(i=limit;i lt rates_total && !IsStopped();i++) { ExtTRBuffer[i]=MathMax(High[i],Close[i-1])-MathMin(Low[i],Close[i-1]); ExtATRBuffer[i]=ExtATRBuffer[i-1]+(ExtTRBuffer[i]-ExtTRBuffer[i-ExtPeriodATR])/ExtPeriodATR; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+