Change color of multiple horizontal lines to another color with a script

 
Hi,

I have several support and resistance horizontal lines with different colors.

I would to have a script where if lets say I have several lines colored yellow the script can loop through all the horizontal lines on my chart that have different colors e.g. yellow,red,brown,find the ones that are yellow in color and change them to my desired color eg blue.

Is there a script I can use to do that.If so please provide me with one.

Thanks
 
Joe Trader:
Hi,

I have several support and resistance horizontal lines with different colors.

I would to have a script where if lets say I have several lines colored yellow the script can loop through all the horizontal lines on my chart that have different colors e.g. yellow,red,brown,find the ones that are yellow in color and change them to my desired color eg blue.

Is there a script I can use to do that.If so please provide me with one.

Thanks

Hi , yes there is . Enjoy (place in scripts)

#property version   "1.00"
#property script_show_inputs
input color FindColor=clrYellow;//find color : 
input color NewColor=clrBlue;//new color : 
input bool changeWidth=false;//change width ?
input int NewWidth=1;//---->new width 
input bool changeStyle=false;//change style ?
input ENUM_LINE_STYLE NewStyle=STYLE_SOLID;//---->new style 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
  int objects=ObjectsTotal(ChartID(),0,OBJ_HLINE);
  for(int i=0;i<objects;i++){
     string obj_name=ObjectName(ChartID(),i,0,OBJ_HLINE);
     color current_color=(color)ObjectGetInteger(ChartID(),obj_name,OBJPROP_COLOR);
     if(current_color==FindColor){
       //recolor
         ObjectSetInteger(ChartID(),obj_name,OBJPROP_COLOR,NewColor);
         if(changeWidth){
           ObjectSetInteger(ChartID(),obj_name,OBJPROP_WIDTH,NewWidth);
           }
         if(changeStyle){
           ObjectSetInteger(ChartID(),obj_name,OBJPROP_STYLE,NewStyle);
           }
       }
     } 
  }
//+------------------------------------------------------------------+
 
Lorentzos Roussos #:

Hi , yes there is . Enjoy (place in scripts)

WOW!This works 100% perfect.Thanks a million.