No matter what I do, I still get :1 errors, 1 warnings
OnCalculate function declared with wrong type or/and parameters PowerfulRedBar.mq4 line 20 column6
OnCalculate function not found in custom indicator line 1 column 1
Any suggestions?
Thanks!!!
Here is what I have:
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
#property indicator_width1 2
extern int minBarsLeft = 5; // Number of bars to the left for comparison
extern int minRangeMultiplier = 2; // Minimum range multiplier for a powerful bar
double buffer[];
void OnInit()
{
IndicatorBuffers(1);
SetIndexBuffer(0, buffer);
SetIndexStyle(0, DRAW_ARROW);
SetIndexArrow(0, 233);
SetIndexLabel(0, "Powerful Red Bar");
}
void OnCalculate(const int rates_total,
const int prev_calculated,
const int begin,
const double& open[],
const double& high[],
const double& low[],
const double& close[],
const long& tick_volume[],
const long& volume[],
const int& spread[])
{
int startBar = MathMax(prev_calculated - minBarsLeft, 0);
for (int i = startBar; i < rates_total; i++)
{
bool isPowerfulRedBar = IsPowerfulRedBar(i, minBarsLeft, minRangeMultiplier, high, low, close, open);
buffer[i] = isPowerfulRedBar ? low[i] - (0.5 * Point) : EMPTY_VALUE;
}
}
bool IsPowerfulRedBar(const int barIndex,
const int numBarsLeft,
const int rangeMultiplier,
const double &high[],
const double &low[],
const double &close[],
const double &open[])
{
double currentRange = high[barIndex] - low[barIndex];
// Check if the bar is red
if (close[barIndex] >= open[barIndex])
return false;
// Check if the bar has the minimum range
if (currentRange < rangeMultiplier * AverageRange(barIndex, numBarsLeft, high, low))
return false;
// Check if the bar has a greater range than the bars to the left
for (int i = 1; i <= numBarsLeft; i++)
{
if ((high[barIndex - i] - low[barIndex - i]) >= currentRange)
return false;
}
return true;
}
double AverageRange(const int startIndex,
const int numBars,
const double &high[],
const double &low[])
{
double sum = 0;
for (int i = startIndex - numBars; i < startIndex; i++)
{
sum += high[i] - low[i];
}
return sum / numBars;
}