Download MetaTrader 5

Draawing Rectangle or Vertical Lines on chart now showing in desired color

To add comments, please log in or register
Abhay Agarwal
168
Abhay Agarwal  

I am trying to draw vertical lines or a single line rectangle at any given bar and I want to display different colors for different conditions. But all vertical line or rectangle is appearing in single color i.e Blue.


The code used to draaw is below, can anyone suggest why it is not showing desired color


   if (!ObjectCreate(0,"TP"+seq,OBJ_RECTANGLE,0,StrToTime(from_chart_time),0,Time[limit-bar+1],2))
   {
      ObjectDelete(0,"TP");
     
      ObjectCreate(0,"TP",OBJ_RECTANGLE,0,StrToTime(from_chart_time),0,Time[limit-bar+1],1000);

      ObjectSetInteger(0,"TP",OBJPROP_FILL,true);
      ObjectSetInteger(0,"TP",OBJPROP_COLOR,clrYellow); 
        ObjectSetInteger(0,"TP",OBJPROP_STYLE,STYLE_SOLID);
        ObjectSetInteger(0,"TP",OBJPROP_WIDTH,2);
        ObjectSetInteger(0,"TP",OBJPROP_BACK,true);

   }
   else
   {
      ObjectSetInteger(0,"TP"+seq+bar_label,OBJPROP_FILL,true);
      ObjectSetInteger(0,"TP"+seq+bar_label,OBJPROP_COLOR,clrYellow);
      ObjectSetInteger(0,"TP"+seq+bar_label,OBJPROP_STYLE,STYLE_DASH);
      ObjectSetInteger(0,"TP"+seq+bar_label,OBJPROP_WIDTH,2);
   }

Files:
Draw_Bars.gif 24 kb
Vladimir Karputov
Moderator
65628
Vladimir Karputov  
Update: the chart must always be one rectangle and one vertical line?
To add comments, please log in or register