how i get support and resistence using icustom in my indicator

 

hi all

i have very good support and resistence indicator i want to add this to my indicator i m using icustom function but everytime it return 0 please check my code 

//+------------------------------------------------------------------+

//|                                                  testsupport.mq4 |

//|                        Copyright 2015, MetaQuotes Software Corp. |

//|                                             https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2015, MetaQuotes Software Corp."

#property link      "https://www.mql5.com"

#property version   "1.00"

#property strict

#property indicator_chart_window


extern ENUM_TIMEFRAMES SupportResistance_TF=PERIOD_D1;

extern int LB=3;

extern int maxBarsForPeriod=1000;

extern bool showH04=true;

extern bool showD01=true;

extern bool showW01=true;

extern bool showMN1=true;

extern double Min_Distance_Support_Resistance=10;

double res;

double sup;

int bar=1;



//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit()

  {

//--- indicator buffers mapping

   

//---

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+

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[])

  {

//---

   

   PivotCalc();

//--- return value of prev_calculated for next call

   return(rates_total);

  }

//+------------------------------------------------------------------+


void PivotCalc()

{

   int i;

   res=0; sup=0;

   for(i=bar;i<=Bars;i++)

   {

      double S1=iCustom(Symbol(),SupportResistance_TF,"Spr",LB,maxBarsForPeriod,showH04,showD01,showW01,showMN1,i);

      double R1=iCustom(Symbol(),SupportResistance_TF,"Spr",LB,maxBarsForPeriod,showH04,showD01,showW01,showMN1,i+1);

      if(res==0 && R1!=EMPTY_VALUE) res=R1;

      if(sup==0 && S1!=EMPTY_VALUE) sup=S1;

      if(res>0 && sup>0) break;

   }

   Comment(res + " - " + sup);

}

 Spr indicator also attach 

Automated Trading and Strategy Testing
Automated Trading and Strategy Testing
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
Files:
Spr.mq4  17 kb
Reason: