
// Standard Deviation Levels  v1.0

#property indicator_chart_window

extern bool Show_Line=true;
extern bool Show_Price=false;
input color UPcol = FireBrick;
input color DOWNcol = Green;
input int style = 0;
extern int Shift = 1;
extern int Width = 150;

datetime curTime;

double up, down;

int xUnit,shift,width;

//-----------------------------------------
int init()
  {
   xUnit   = Period() * 60;
   shift   = Shift * xUnit;
   width   = Width * xUnit;
  

   return(0);
  }
//-----------------------------------------
int deinit()
  {

ObjectDelete("up_line");   
ObjectDelete("down_line");    
ObjectDelete("up_price");   
ObjectDelete("down_price");     

   return(0);
  }
//-----------------------------------------
int start()
  {


   up=iBands(0,1,20,2,0,0,1,0); 
   down=iBands(0,1,20,2,0,0,2,0); 

   curTime = Time[0];
   
 if (Show_Line==true) 
   { 
   ObjectDelete("up_line");
   ObjectCreate(0,"up_line",OBJ_TREND,0,0,0,0);
   ObjectSet("up_line", OBJPROP_TIME1,  curTime+shift);
   ObjectSet("up_line", OBJPROP_TIME2,  curTime+shift+width);
   ObjectSet("up_line", OBJPROP_PRICE1, up);
   ObjectSet("up_line", OBJPROP_PRICE2, up);
   ObjectSet("up_line",OBJPROP_STYLE,style);
   ObjectSet("up_line",OBJPROP_COLOR,UPcol);
   ObjectSet("up_line",OBJPROP_RAY,false);
   
   ObjectDelete("down_line");
   ObjectCreate(0,"down_line",OBJ_TREND,0,0,0,0);
   ObjectSet("down_line", OBJPROP_TIME1,  curTime+shift);
   ObjectSet("down_line", OBJPROP_TIME2,  curTime+shift+width);
   ObjectSet("down_line", OBJPROP_PRICE1, down);
   ObjectSet("down_line", OBJPROP_PRICE2, down);
   ObjectSet("down_line",OBJPROP_STYLE,style);
   ObjectSet("down_line",OBJPROP_COLOR,DOWNcol);
   ObjectSet("down_line",OBJPROP_RAY,false);
   }
   
 if (Show_Price==true) 
   { 
   ObjectDelete("up_price");
   ObjectCreate(0,"up_price",OBJ_HLINE,0,0,up);
   ObjectSet("up_price",OBJPROP_STYLE,5);
   ObjectSet("up_price",OBJPROP_COLOR,UPcol);
   
   ObjectDelete("down_price");
   ObjectCreate(0,"down_price",OBJ_HLINE,0,0,down);
   ObjectSet("down_price",OBJPROP_STYLE,5);
   ObjectSet("down_price",OBJPROP_COLOR,DOWNcol);
   }
   return(0);
  }

