Average True Range ATR Indicator For MT5
Table Of Contents:
- Average True Range ATR Indicator For MT5
- Instalar la Average True Range ATR Indicator For MT5
- Parámetros de la Average True Range ATR Indicator For MT5
- Buffers of the Average True Range ATR Indicator For MT5
- Partes principales del código
El Average True Range ATR Indicator For MT5 es uno de los indicadores estándar muy famosos en casi todas las plataformas de negociación. Se utiliza como base para muchos otros indicadores que usan sus valores como entrada para el cálculo adicional. El indicador ATR calcula el tamaño promedio de las velas X recientes. Los valores le permiten ver un aumento o disminución de la volatilidad en el mercado.
Instalar la Average True Range ATR Indicator For MT5
Después de descargar el indicador a través del formulario anterior, debe descomprimir el archivo zip. Luego, debe copiar el archivo atr.mq5 en la carpeta MQL5Indicators de su instalación MT5 . Después de eso, reinicie MT5 y luego podrá ver el indicador en la lista de indicadores.
Parámetros de la Average True Range ATR Indicator For MT5
Average True Range ATR Indicator For MT5 tiene parámetros 1 para configurar.
input int InpAtrPeriod=14; // ATR period
Buffers of the Average True Range ATR Indicator For MT5
Average True Range ATR Indicator For MT5 proporciona buffers 2 .
SetIndexBuffer(0,ExtATRBuffer,INDICATOR_DATA); SetIndexBuffer(1,ExtTRBuffer,INDICATOR_CALCULATIONS);
Partes principales del código
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); } //+------------------------------------------------------------------+