I am trying to build an indicator that returns data ranges on upbars (i.e. close - low). There is no problem here but when I am trying to get the averages of these data the indicator uses also the downbars on their calculates (it takes 0 like value of downbars). I want to use only the upbars on the average calculate.
protected override void OnBarUpdate()
{
if (CurrentBar < AvPeriod)
return;
else
{
if (BarUp && Close[0] > Open[0])
{
OpenClose.Set(Close[0] - Open[0]);
}
}
double sumOC = 0;
for(int i=0; i<AvPeriod; i++)
{
sumOC = sumOC + OpenClose[i];
}
OCAv.Set(sumOC/AvPeriod);
Print(sumOC/AvPeriod);
Comment