Iervolino: the candle colors displayed aren't correct
if (close[i] > close[i - 1] && buffer_ma[i] > buffer_ma[i - 1]) { candle_color[i] = 0; } else if (close[i] < close[i - 1] && buffer_ma[i] < buffer_ma[i - 1]) { candle_color[i] = 1; } else What color do you set here? // Your code (above) code rewritten for clarity (below:) if (buffer_ma[i] > buffer_ma[i - 1]) { if (close[i] > close[i - 1]) candle_color[i] = 0; else What color do you set here? } else { if (close[i] < close[i - 1]) candle_color[i] = 1; else what color do you set here? }
whroeder1:
Thank you!
Is it correct now?
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 == 0) { start = 1; } else { start = prev_calculated - 1; } CopyBuffer(MA, 0, 0, rates_total, buffer_ma); for (int i = start; i < rates_total; i++) { buffer_open[i] = open[i]; buffer_high[i] = high[i]; buffer_low[i] = low[i]; buffer_close[i] = close[i]; if (buffer_ma[i] > buffer_ma[i - 1]) { ma_color[i] = 0; if (close[i] > close[i - 1]) candle_color[i] = 0; else candle_color[i] = EMPTY_VALUE; } else if (buffer_ma[i] < buffer_ma[i - 1]) { ma_color[i] = 1; if (close[i] < close[i - 1]) candle_color[i] = 1; else candle_color[i] = EMPTY_VALUE; } else { ma_color[i] = 2; candle_color[i] = EMPTY_VALUE; } } return(rates_total); }

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
There's a bug in the indicator I made where most of the times I add the indicator to the graph, the candle colors displayed aren't correct.
The bug can be seen in the video below (the second time I add the indicator the colors are right):
https://streamable.com/9pvqf
Code: