//+------------------------------------------------------------------+ // ATR.mq5 //…
- User
//+------------------------------------------------------------------+ //| ATR.mq5 | //| Copyright 2024, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2024, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00" #property indicator_separate_window #property indicator_buffers 1 #property indicator_plots 1
#property indicator_label1 "ATR" #property indicator_type1 DRAW_LINE #property indicator_color1 clrRed #property indicator_style1 STYLE_SOLID #property indicator_width1 1
//— input parameters input int InpAtrPeriod = 10; // ATR period
//— indicator buffers double AtrBuffer[];
//±-----------------------------------------------------------------+ //| Custom indicator initialization function | //±-----------------------------------------------------------------+ int OnInit() { SetIndexBuffer(0, AtrBuffer,INDICATOR_DATA); return(INIT_SUCCEEDED); } //±-----------------------------------------------------------------+ //| Custom indicator iteration function | //±-----------------------------------------------------------------+ 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 &tick_volume[], const long &volume[], const int &spread[]) { double H_L[10]; int m = 0; double openATR[10]; // Calculate moving average and MADiff for(int i = rates_total-1; i > rates_total-InpAtrPeriod-1; i--) { double maxHigh = high[i]; double minLow = low[i]; openATR[m] = open[i]; H_L[m] = NormalizeDouble(maxHigh - minLow,_Digits); m++; }
double ATR; for(int i=0;i<9;i++) { double sum = H_L[i]+H_L[i+1]; ATR += NormalizeDouble(sum/2/openATR[i+1]*100,2); Print(ATR); }
return(rates_total); } //±-----------------------------------------------------------------+ выводит ошибку possible use of uninitialized variable 'ATR' ATR.mq5 64 7 что делать
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.