Or perhaps the code below is more simple (no Global or int init() variables required), it seems to work fine...
PHP Code:
//+----------------------------------------------------------------------------------------+
//| Custom indicator iteration function |
//+----------------------------------------------------------------------------------------+
int start()
{
// Auto 5/6 Digit Broker Quote Switch.
double DblPoints; if(Digits==5||Digits==3) {DblPoints=Point*10;} else {DblPoints=Point;}
// Auto JPY Pair Style Digit Display Switch.
double SP1; if(Digits==3) {SP1=Digits-2;} else {SP1=Digits-4;}
// Spread.
double SPRD=(Ask-Bid)/DblPoints;
string SPREAD=DoubleToStr(SPRD,SP1);