I need help in this breakout entry by i custom calling

 

Please help me this error. I use this custom indicator to call its function it has two breakout line up and down . I want to buy when price breakout at upper line and sell breakout at lower line. here is picture

  

 #property indicator_chart_window
    #property indicator_buffers 2
    #property indicator_color1 Green
    #property indicator_color2 Red
    #property indicator_width1 2
    #property indicator_width2 2
    #property indicator_style1 STYLE_SOLID
    #property indicator_style2 STYLE_SOLID

    //-- External variables
    extern int StPeriod   = 10;

    //-- Buffers
    double FextMapBuffer1[];
    double FextMapBuffer2[];

    //+------------------------------------------------------------------+
    //| Custom indicator initialization function                         |
    //|------------------------------------------------------------------|
    int init()
    {   
       SetIndexStyle(0,DRAW_LINE);
       SetIndexBuffer(0, FextMapBuffer1);
       SetIndexStyle(1,DRAW_LINE);
       SetIndexBuffer(1,FextMapBuffer2);        
       IndicatorShortName("Stretch Breakout Channel ("+ StPeriod +")");
       Comment("Copyright © http://www.pointzero-trading.com");
       return(0);
    }

    //+------------------------------------------------------------------+
    //| Custom indicator deinitialization function                       |
    //+------------------------------------------------------------------+
    int deinit()
    {
       return(0);
    }

    //+------------------------------------------------------------------+
    //| Custom indicator iteration function                              |
    //+------------------------------------------------------------------+
    int start()
    {
       // Start, limit, etc..
       int start = 0;
       int limit;
       int counted_bars = IndicatorCounted();
       
       // nothing else to do?
       if(counted_bars < 0) 
           return(-1);

       // do not check repeated bars
       limit = Bars - 1 - counted_bars;
       
       // Iteration
       for(int pos = limit; pos >= start; pos--)
       {
          int dshift = iBarShift(Symbol(), PERIOD_D1, Time[pos], false);
          double stretch = iCustom(Symbol(), PERIOD_D1, "Stretch", StPeriod, 0, dshift+1);
          double OPEN = iOpen(Symbol(),  PERIOD_D1, dshift);
          FextMapBuffer1[pos] = OPEN + stretch;
          FextMapBuffer2[pos] = OPEN - stretch;
       }
       return(0);
    }


I call it custom function by i Custom like this


        int a = iCustom(NULL,0,"stretchbreakoutchannel",0,0); //up
        int b = iCustom(NULL,0,"stretchbreakoutchannel",1,0); //down

I try to buy and sell at breakout its line

  if ( OrdersTotal() == 0 ){
           if (New_Bar())
           if ( Open[0] <= Open[StartHour] )
               {
                if (Close[1]< a)//if price above a line
                 {
                  int ticket = OrderSend ( Symbol(),OP_BUY ,SetLotSize(), Ask, 3, Ask-StopLoss*Point,Ask+TakeProfit*Point,MagicNumber,"Set by system");
                  if ( ticket < 0 )
                  {
                    Alert("Error");
                  }
                 }
               }
               else
               {
                 if (Close[1]>b) //if price below b line
                 {
                   int ticket = OrderSend ( Symbol(),OP_SELL ,SetLotSize() , Bid, 3, Bid+StopLoss*Point,Bid-TakeProfit*Point,MagicNumber,"Set by system");
                  if ( ticket < 0 )
                  {
                    Alert("Error");
                  }
               }
              }
      }

   
         bool New_Bar() {
   static datetime New_Time=0; // New_Time = 0 when New_Bar() is first called
   if(New_Time!=Time[0]){      // If New_Time is not the same as the time of the current bar's open, this is a new bar
      New_Time=Time[0];        // Assign New_Time as time of current bar's open
      return(true);
   }
   return(false);
   }


opening buy and sell orders are very bad .They not open at breakout point .I code to open buy when price over a line but it not open as this.

What wrong in this code.

Can someone edit it.

What knowledge still need to code such breakout entry signal by i custom

 
      int a = iCustom(NULL,0,"stretchbreakoutchannel",0,1); //up
      int b = iCustom(NULL,0,"stretchbreakoutchannel",1,1); //down


if (Close[1] > a) //if price above a line

if (Close[1] < b) //if price below b line