# Need some clarification ... use of continue in if..loop

[Deleted]

NOTE: The continue operator passes control to the beginning of the nearest outward loop (while, do-while or for) operator, the next iteration being called.

please CORRECT Me, if I am wrong ...

```   for (int i = (int)MathMax(prev_calculated-1,0); i < rates_total; i++)
{
double vol;
double price = getPrice(Price,open,close,high,low,i,rates_total);
if(RealV)
vol = (double)volume[i];
else
vol = (double)tick_volume[i];

if(i < 2)	// Calculate when i = 0 or i = 1
{
VEMAs[i][_nFastMA] = (vol*price);
VEMAs[i][_dFastMA] = (vol);
VEMAs[i][_nSlowMA] = (vol*price);
VEMAs[i][_dSlowMA] = (vol);
continue;
}
//--- following section will be executed when i >=2 and < rates_total ?
VEMAs[i][_nFastMA] = VEMAs[i-1][_nFastMA] + alphaFast *(vol*price - VEMAs[i-1][_nFastMA]);
VEMAs[i][_dFastMA] = VEMAs[i-1][_dFastMA] + alphaFast *(vol       - VEMAs[i-1][_dFastMA]);
VEMAs[i][_EMAFast] = VEMAs[i][_nFastMA] / VEMAs[i][_dFastMA];

VEMAs[i][_nSlowMA] = VEMAs[i-1][_nSlowMA] + alphaSlow *(vol*price - VEMAs[i-1][_nSlowMA]);
VEMAs[i][_dSlowMA] = VEMAs[i-1][_dSlowMA] + alphaSlow *(vol       - VEMAs[i-1][_dSlowMA]);
VEMAs[i][_EMASlow] = VEMAs[i][_nSlowMA] / VEMAs[i][_dSlowMA];

MACD_Main[i]   = VEMAs[i][_EMAFast] - VEMAs[i][_EMASlow];
MACD_Signal[i] = MACD_Signal[i-1] + alphaSignal * (MACD_Main[i] - MACD_Signal[i-1]);
OscMAUp[i]     = MACD_Main[i] - MACD_Signal[i];
}
return(rates_total);
}```

The section will be executed when i >1 AND i < rates_total.

[Deleted]
Dominik Egert:
The section will be executed when i >1 AND i < rates_total.

Thanks Dominik, I guess you are referring the lower part of the code (not if..loop).

Just read the documentation, and updated my comment, which seems agreeing with your statement.

Just curious when MACD_Main, Signal, OscMAUp and OscMAUp are not calculated for i[0] and i[1], how come the indicator still shows value for them !!!

This could be due to memory not being initialized.

Initialize it with zero and see if it works as expected.

[Deleted]
Dominik Egert:
This could be due to memory not being initialized.

Initialize it with zero and see if it works as expected.

Hi Dominik

the above is partial code from Volume Weighted MACD Indicator by 'copyright mladen www.forex-tsd.com' and feel no problem with it.

just trying to understand how this code return values for [0] and [1] bar, while the code suggest they are not calculated.

I have attached the Indicator Code mq5 file, in case you want to dive deep into it and suggest.

Files:
Reason: