Hello, I need your help! for my first indicator!

 

I am trying to make instead of drawing lines draw a rectangle thanks who can help me

//+------------------------------------------------------------------+
//|                                                    MU.mq4 |
//|                                                 Copyright © 2020 |
//|                                        |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""
#property description "" 
#property description "        "
#property description "()"
#property description "        "
#property description "()"
#property icon "iconoo.ico"
#property indicator_chart_window

#property indicator_buffers 2
#property indicator_color1 PaleGreen
#property indicator_color2 Red

extern int StartHour=15;
extern int EndHour=23;



double UpperCh[], LowerCh[];

int init()
  {
   IndicatorDigits(Digits);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,UpperCh);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,LowerCh);

   return(0);
  }

int deinit()
  {
   
   return(0);
  }
  
int start()
  {
   if(Bars<=3) return(0);
   int ExtCountedBars=IndicatorCounted();
   if (ExtCountedBars<0) return(-1);
   int    pos=Bars-2;
   if(ExtCountedBars>2) pos=Bars-ExtCountedBars-1;
   while(pos>0)
     {
      datetime EndTime=StrToTime(TimeToStr(Time[pos],TIME_DATE)+" "+DoubleToStr(EndHour,0)+":00");
      if (Time[pos]>=EndTime && Time[pos+1]<EndTime)
      {
       double MaxPrice=High[pos];
       double MinPrice=Low[pos];
       datetime StartTime=StrToTime(TimeToStr(Time[pos],TIME_DATE)+" "+DoubleToStr(StartHour,0)+":00");
       if (StartHour>EndHour) StartTime=StartTime-86400;
       int pos_=pos;
       while (pos_<Bars && Time[pos_]>=StartTime)
       {
        MinPrice=MathMin(MinPrice, Low[pos_]);
        MaxPrice=MathMax(MaxPrice, High[pos_]);
        pos_++;
       }
       int i;
       for (i=pos_-1;i>=pos;i--)
       {
        UpperCh[i]=MaxPrice;
        LowerCh[i]=MinPrice;
       }
       if (pos!=pos_-1)
       {
        string ObjName="ChannelSizeLabel "+TimeToStr(Time[pos],TIME_DATE);
        
        if (ObjectFind(ObjName)==-1)
        {
         
        }
        else
        {
         ObjectSet(ObjName,OBJPROP_PRICE1,MinPrice);
        } 
        
       } 
      }
      else
      {
       UpperCh[pos]=EMPTY_VALUE;
       LowerCh[pos]=EMPTY_VALUE;
      }
      pos--;
     }

   return(0);
  }

Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
  • www.mql5.com
When creating a custom indicator, you can specify one of 18 types of graphical plotting (as displayed in the main chart window or a chart subwindow), whose values are specified in the ENUM_DRAW_TYPE enumeration. Depending on the drawing style, you may need one to four value buffers (marked as INDICATOR_DATA). If a style admits dynamic...
 
In future please post in the correct section
I will move your topic to the MQL4 and Metatrader 4 section.

 
Deibys marrero: I am trying to make instead of drawing lines draw a rectangle thanks who can help me
  1. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

  2. You don't draw rectangles with buffers.
 
Deibys marrero:

I am trying to make instead of drawing lines draw a rectangle thanks who can help me

Haha, yup. You don't draw rectangle with buffers (can you? i don't know).

Refer this documentation. I think the direction on the documentation is simple enough.

OBJ_RECTANGLE - Object Types - Objects Constants - Constants, Enumerations and Structures - MQL4 Reference
OBJ_RECTANGLE - Object Types - Objects Constants - Constants, Enumerations and Structures - MQL4 Reference
  • docs.mql4.com
The following script creates and moves the rectangle on the chart. Special functions have been developed to create and change graphical object's properties. You can use these functions "as is" in your own applications. //| Create rectangle by the given coordinates                        |               time1=0,           ...
Reason: