Beginner: please help fix my code error

 
Hi,
Beginner.....I wrote a very simple code. Please help me find out why "name" and "typ" turned out empty or something ?
MT4 says:
object name passed to ObjectType function cannot be an uninitialized or empty string

//+------------------------------------------------------------------+
//|                                                       ob try.mq4 |
//|                       Copyright ?2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2006, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   return(0);
  }
int deinit()
  {
   return(0);
  }                            
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
     int    i=ObjectsTotal();
     int    typ;
  string name;
  
     name=ObjectName(i);
     typ=ObjectType(name);
     Print("obj number:" + i);
     Print("last obj name:"+ name);
     Print("last obj type:"+ typ);
//----
 //  return(0);
  }





BTW, "int start()" runs once when every tick happens once, am I right ?

 
name=ObjectName(i-1);
===
string ObjectName( int index)
The function returns the object name by its index in the objects list. To get the detailed error information, one has to call the GetLastError() function.
Parameters:
index - Object index in the objects list. Object index must exceed or equal to 0 and be less than ObjectsTotal().
===
 
Thanks a lot, Slawa. That made a breakthrough for me ! Now I have got my first break_alert indicator, very useful.
Reason: