Check this code why it doesnt work

To add comments, please log in or register
Brian Lillard
9219
Brian Lillard  
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window

//+------------------------------------------------------------------+
int OnInit(){return(INIT_SUCCEEDED);}
//+------------------------------------------------------------------+
int deinit()
 { 
 for(int i=Bars; i>=0; i--)  
  {
  ObjectDelete(NULL,"H:"+IntegerToString(Time[i]));
  ObjectDelete(NULL,"L:"+IntegerToString(Time[i]));
  }
 return(0); 
 }
//+------------------------------------------------------------------+
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 i,limit,counted_bars=IndicatorCounted();
 limit=Bars-counted_bars;
 for(i=limit; i>=0; i--)  
  {
  TEXT("H:"+IntegerToString(Time[i]),Time[i],High[i]+iATR(NULL,0,14,i),DoubleToStr(High[i]-Open[i]),"Arial",7,White);
  TEXT("L:"+IntegerToString(Time[i]),Time[i],Low[i]-iATR(NULL,0,14,i),DoubleToStr(Open[i]-Low[i]),"Arial",7,White);
  }
 return(rates_total);
 }
//+------------------------------------------------------------------+
void TEXT(string sName,datetime dTime,double dPrice,string sText,string sFont,int iFontSize,color cFontColor)  
 {
 ObjectDelete(sName);
 ObjectCreate(sName,OBJ_TEXT,0,dTime,dPrice);
 ObjectSetText(sName,sText,iFontSize,sFont,cFontColor);  
 }
//+------------------------------------------------------------------+
Files:
PTS-HL.mq4 2 kb
Marco Montemari
14251
Marco Montemari  
Brian Lillard:
deinit... is not case sensitive?
Nagisa Unada
634
Nagisa Unada  
Since the "counted_bars" has 0 when the program has started up, the value of limit is equal to Bars. So it causes an "array out of range" error.
Brian Lillard
9219
Brian Lillard  
Well cool thank for all the input. I haven't gotten it working as of yet though and was wondering if any of you have?
To add comments, please log in or register