problem with coloring background

 

Hello friends. When applying background colors most of the lines on chart go invisible, no matter how light the background color is! Is there a solution?


 

You have to consider the RGB components of the selected colours, because the colours get mixed to form a new colour which could end up having very little contrast against each other.

So, you have to consider a little bit of colour theory in your selections, or reconsider how you wish to represent your indicator.

 
Yashar Seyyedin:

Hello friends. When applying background colors most of the lines on chart go invisible, no matter how light the background color is! Is there a solution?


Find opposite color automatically mql

If the bands are stable and the indicator min max is stable too you can revert to semitransparent boxes via resources or canvas (which you will have to adjust when chart changes size)

Otherwise i had a library for opposite colors , but i have to apologize for the coding style back then when i built it. 

Here is a test , the degrees of hue determine how much "punch" the new color will have in contrast to the select color .(so 180 degrees is the max contrast hypothetically)

I tested only with pink and red today

#property copyright "Discussion"
#property link      "https://www.mql5.com/en/forum/440922"

input color selectColor=clrPink;//Select a color
input double hueDegrees=180.0;//Degrees
#include <PlugAndPlay\colors\hslToRgbAndOppositeColors.mqh>

int OnInit()
  {
//---
  int back_size=200;
  int front_size=150;
  int dev=(back_size-front_size)/2;
  ObjectsDeleteAll(ChartID(),"COLOR_");
  ObjectCreate(ChartID(),"COLOR_BACK",OBJ_RECTANGLE_LABEL,0,0,0);
  ObjectSetInteger(ChartID(),"COLOR_BACK",OBJPROP_XSIZE,back_size);
  ObjectSetInteger(ChartID(),"COLOR_BACK",OBJPROP_YSIZE,back_size);
  ObjectSetInteger(ChartID(),"COLOR_BACK",OBJPROP_XDISTANCE,0);
  ObjectSetInteger(ChartID(),"COLOR_BACK",OBJPROP_YDISTANCE,0);
    
  ObjectCreate(ChartID(),"COLOR_FRONT",OBJ_RECTANGLE_LABEL,0,0,0); 
  ObjectSetInteger(ChartID(),"COLOR_FRONT",OBJPROP_XSIZE,front_size);
  ObjectSetInteger(ChartID(),"COLOR_FRONT",OBJPROP_YSIZE,front_size);  
  ObjectSetInteger(ChartID(),"COLOR_FRONT",OBJPROP_XDISTANCE,dev);
  ObjectSetInteger(ChartID(),"COLOR_FRONT",OBJPROP_YDISTANCE,dev);
  
  //color 1 in the back 
    ObjectSetInteger(ChartID(),"COLOR_BACK",OBJPROP_BGCOLOR,selectColor);
    ObjectSetInteger(ChartID(),"COLOR_BACK",OBJPROP_BORDER_COLOR,selectColor);
  //color 2 in the fron
    color hypoth=OppositeOf(selectColor,hueDegrees);
    ObjectSetInteger(ChartID(),"COLOR_FRONT",OBJPROP_BGCOLOR,hypoth);
    ObjectSetInteger(ChartID(),"COLOR_FRONT",OBJPROP_BORDER_COLOR,hypoth);
    ChartRedraw();    
//---
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
//--- 
  ObjectsDeleteAll(ChartID(),"COLOR_");
  }

void OnTick()
  {

   
  }
 
Lorentzos Roussos #:

Find opposite color automatically mql

If the bands are stable and the indicator min max is stable too you can revert to semitransparent boxes via resources or canvas (which you will have to adjust when chart changes size)

Otherwise i had a library for opposite colors , but i have to apologize for the coding style back then when i built it. 

Here is a test , the degrees of hue determine how much "punch" the new color will have in contrast to the select color .(so 180 degrees is the max contrast hypothetically)

I tested only with pink and red today

This is cool bro. Thanks 
 

You can also play with combinations here on this interactive color wheel


Reason: