Code: Select all
#property indicator_chart_window
int downArrowCount = 0;
int upArrowCount = 0;
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[])
{
for (int i = prev_calculated; i < rates_total; i++)
{
// Check for down arrow and downward close
if (low[i] < low[i - 1] && close[i] < close[i - 1])
{
downArrowCount++;
}
// Check for up arrow and upward close
else if (high[i] > high[i - 1] && close[i] > close[i - 1])
{
upArrowCount++;
}
}
// Update the dashboard or print the values
// You can use the Chart functions or print to the Experts tab in the Terminal window
// Example: ChartIndicatorAdd(0, downArrowCount);
// Example: ChartIndicatorAdd(1, upArrowCount);
// Example: Print("Down Arrow Count: ", downArrowCount, " Up Arrow Count: ", upArrowCount);
return rates_total;
}