Hi All,
I wrote the simple indicator. I want this indicator in the separated windows. the first run in OnCalculated function is working correct. But the updated the value is not proper as shown in the picture. It seems it just show the closed value in green.
Candle1Buffer1[index_calc] = open[index_calc]; Candle1Buffer2[index_calc] = high[index_calc]; Candle1Buffer3[index_calc] = low[index_calc]; Candle1Buffer4[index_calc] = close[index_calc];
Candle1Buffer1[i] = open[i]; Candle1Buffer2[i] = high[i]; Candle1Buffer3[i] = low[i]; Candle1Buffer4[i] = close[i];
Yashar Seyyedin #:
You may check documentation for ObjectDelete and ObjectCreate. The first input parameter is chart id.
My problem is the candles that I showed in circle. I do not know why those have one value of candle.
Hi Le,
there is no difference in the behaviour. both of them show a small green line for further calling of OnCalculated.
Best Regards,
Mostafa
Dont use static variable like that, you will get array out of range if you want you indicator repaint every tick
int start = 0; if(prev_calculated==0) start=0; else start=prev_calculated-1; ... Candle1Buffer1[i] = open[i]; Candle1Buffer2[i] = high[i]; Candle1Buffer3[i] = low[i]; Candle1Buffer4[i] = close[i];
Here's how you can adjust your OnCalculatefunction to address these issues:
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[]) { int start; if(prev_calculated > 1) start = prev_calculated - 1; // Start from the last known point to update it else start = 0; // Start from scratch if no previous calculations for(int i = start; i < rates_total && !IsStopped(); i++) { // Directly use 'i' to index into your buffers Candle1Buffer1[i] = open[i]; Candle1Buffer2[i] = high[i]; Candle1Buffer3[i] = low[i]; Candle1Buffer4[i] = close[i]; } DrawLine(); return(rates_total); }
Hello, please I'm having an issue with the mt5 update.
Read this: https://www.mql5.com/en/forum/462316
- 2024.02.12
- Le Minh Duc
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi All,
I wrote the simple indicator. I want this indicator in the separated windows. the first run in OnCalculated function is working correct. But the updated the value is not proper as shown in the picture. It seems it just show the closed value in green.