Download MetaTrader 5

Filled Rectangles in MT4

To add comments, please log in or register
Post web links to other trader's signals and make profit
jakubdonovan36
237
jakubdonovan36 2015.03.12 14:38 
Hello lads, so i have been trying to get this to work via Meta Editor but i am no coder so as you might have guessed, i haven't been successful at all. Does anyone have any idea how to make it so that the rectangles in MT4 are filled with colour?
honest_knave
Moderator
2242
honest_knave 2015.03.12 15:30  
jakubdonovan36
237
jakubdonovan36 2015.03.12 15:34  
honest_knave:

OBJPROP_FILL

 

But where do i do that? mind guiding me?
honest_knave
Moderator
2242
honest_knave 2015.03.12 15:38  

Sure, post up your code that creates the rectangle and I'll show you where it goes.

jakubdonovan36
237
jakubdonovan36 2015.03.12 15:49  
honest_knave:

Sure, post up your code that creates the rectangle and I'll show you where it goes.

+------------------------------------------------------------------+
//| Create object "Rectangle"                                        |
//+------------------------------------------------------------------+
bool CChartObjectRectangle::Create(long chart_id,const string name,const int window,
                                   const datetime time1,const double price1,
                                   const datetime time2,const double price2)
  {
   if(!ObjectCreate(chart_id,name,OBJ_RECTANGLE,window,time1,price1,time2,price2))
      return(false);
   if(!Attach(chart_id,name,window,2))
      return(false);
//--- successful
   return(true);
  }
honest_knave
Moderator
2242
honest_knave 2015.03.12 16:14  
+------------------------------------------------------------------+
//| Create object "Rectangle"                                        |
//+------------------------------------------------------------------+
bool CChartObjectRectangle::Create(long chart_id,const string name,const int window,
                                   const datetime time1,const double price1,
                                   const datetime time2,const double price2)
  {
   if(!ObjectCreate(chart_id,name,OBJ_RECTANGLE,window,time1,price1,time2,price2))
      return(false);
   ObjectSetInteger(chart_id,name,OBJPROP_FILL,true);
   if(!Attach(chart_id,name,window,2))
      return(false);
//--- successful
   return(true);
  }
jakubdonovan36
237
jakubdonovan36 2015.03.12 16:24  
honest_knave:

did that and it still doesn't work. When I check ''draw object as background'' the whole thing becomes transparent and disappears, but when i leave it unchecked, the shape is still empty :/
whroeder1
14544
whroeder1 2015.03.12 16:37  
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. compare your post
    jakubdonovan36: It still doesn't work.
    //   ObjectSetInteger(chart_id,name,OBJPROP_FILL,clrGray);  LINE ?
    with my suggestion.
    honest_knave:
      ObjectSetInteger(chart_id,name,OBJPROP_FILL,true);  LINE 1
    You say to fill it, but don't set what color to fill. From ObjectSetInteger - MQL4 Documentation
    ObjectSetInteger(0,name,OBJPROP_COLOR,clrBlack);         LINE 2
jakubdonovan36
237
jakubdonovan36 2015.03.12 16:45  
WHRoeder:
You say to fill it, but don't set what color to fill. From ObjectSetInteger - MQL4 Documentation



It still doesn't work.

//| Create object "Rectangle"                                        |
//+------------------------------------------------------------------+
bool CChartObjectRectangle::Create(long chart_id,const string name,const int window,
                                   const datetime time1,const double price1,
                                   const datetime time2,const double price2)
  {
   if(!ObjectCreate(chart_id,name,OBJ_RECTANGLE,window,time1,price1,time2,price2))
      return(false);
   ObjectSetInteger(chart_id,name,OBJPROP_FILL,clrGray);
   if(!Attach(chart_id,name,window,2))
      return(false);
//--- successful
   return(true);
jakubdonovan36
237
jakubdonovan36 2015.03.12 17:17  
WHRoeder:
You say to fill it, but don't set what color to fill. From ObjectSetInteger - MQL4 Documentation



Any suggestions on how to make thins work?
jakubdonovan36
237
jakubdonovan36 2015.03.12 17:17  
honest_knave:

Any suggestions on how to make this work?
12345
To add comments, please log in or register