Need help with my first indicator Ice Dollar index

 

Hi

I am trying to create my first indicator, the indicator calculates ICE Dollar index based

the indicator does not seem to constantly draw line (on every tick the indicator tends to disappear totally and re appear)

on changing the periodicity the indicator disappears and indicator window is blank.

Here  is the code

 

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[])
  {
     int limit;
  //---- check for possible errors
     if(prev_calculated<0) return(-1);
  //---- the last counted bar will be recounted
     if(prev_calculated>0) prev_calculated--;
     limit=Bars(_Symbol,_Period)-prev_calculated;
  //---- main loop
     for(int i=0; i<limit; i++)
       {
        DXYBuffer[i]=50.14348112 * MathPow(iClose("EURUSD",0,i),-0.576) * MathPow(iClose("USDJPY",0,i),0.136) * 
                     MathPow(iClose("GBPUSD",0,i),-0.119) * MathPow(iClose("USDCAD",0,i),0.091) * 
                     MathPow(iClose("USDSEK",0,i),0.042) * MathPow(iClose("USDCHF",0,i),0.036);
       }
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
double iClose(string symbol,int tf,int index)
{
   if(index < 0) return(-1);
   double Arr[];
   ENUM_TIMEFRAMES timeframe=_Period;
   if(CopyClose(symbol,timeframe, index, 1, Arr)>0) return(Arr[0]);
   else return(-1);
}

Appreciate your help 

Thanks

Bashir 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
  • www.mql5.com
Standard Constants, Enumerations and Structures / Indicator Constants / Drawing Styles - Documentation on MQL5
 
Does nothing because prev_calculated is const:
if(prev_calculated>0) prev_calculated--;
Try printing prev_calculated each call of OnCalculate(). It will probably show: 0, 999, 0, 999, ... With 999 being your total bars on the chart.