Vignetta

This is a programming idea for displaying two numbers i.e. a percentage or an oscillator’s reading as 2 balls visible from the other side of the room. The color gets changed in certain ranges. This routine does not deal with the decimals.

Here the two numbers represent the price’s location relative to the E-32 channel.

deletetxt1("Vignetta");


int twodigits = NormalizeDouble(100-((top_of_the_range-Close[0])/(top_of_the_range-bottom_of_the_range)*100),0);


int tens = round(twodigits/10);

int ones = twodigits-tens*10; 

string stens, sones;



switch(tens)
{
case  1:   stens=CharToStr(140);
        break;
case  2:   stens=CharToStr(141);
        break;
case  3:   stens=CharToStr(142);
        break;        
case  4:   stens=CharToStr(143);
        break;
case  5:   stens=CharToStr(144);
        break;
case  6:   stens=CharToStr(145);
        break;        
case  7:   stens=CharToStr(146);
        break;                
case  8:   stens=CharToStr(147);
        break;                        
case  9:   stens=CharToStr(148);
        break;                      
  default: stens=CharToStr(139);
      break;
  }
  

switch(ones)
{
case  1:   sones=CharToStr(140);
        break;
case  2:   sones=CharToStr(141);
        break;
case  3:   sones=CharToStr(142);
        break;        
case  4:   sones=CharToStr(143);
        break;
case  5:   sones=CharToStr(144);
        break;
case  6:   sones=CharToStr(145);
        break;        
case  7:   sones=CharToStr(146);
        break;                
case  8:   sones=CharToStr(147);
        break;                        
case  9:   sones=CharToStr(148);
        break;                      
  default: sones=CharToStr(139);
      break;
  }
 

 
string jointstring=stens+sones;

 ObjectCreate("Vignetta",OBJ_LABEL,0,0,0,0,0);
         ObjectSet("Vignetta",OBJPROP_XDISTANCE,3*15); 
         ObjectSet("Vignetta",OBJPROP_YDISTANCE,3*15);

if (100-((top_of_the_range-Close[0])/(top_of_the_range-bottom_of_the_range)*100)>=60 && 100-((top_of_the_range-Close[0])/(top_of_the_range-bottom_of_the_range)*100)<=70 )  ObjectSetText("Vignetta",jointstring,80,"Wingdings",Crimson);
else if (100-((top_of_the_range-Close[0])/(top_of_the_range-bottom_of_the_range)*100)>=30 && 100-((top_of_the_range-Close[0])/(top_of_the_range-bottom_of_the_range)*100)<=40 )   ObjectSetText("Vignetta",jointstring,80,"Wingdings",Green);  
else if (ones<5 && tens<1)  ObjectSetText("Vignetta",jointstring,80,"Wingdings",Green);
else if (ones>3 && tens==9)  ObjectSetText("Vignetta",jointstring,80,"Wingdings",Crimson);
else ObjectSetText("Vignetta",jointstring,80,"Wingdings",Brown);
To put numbers on an indicator, you would have to change the first 0 in the ObjectCreate parameters to 1, 2 etc. which is the indicator_window number

The deletetxt1 routine came from somewhere, I just made it more universal.

   void deletetxt1(string text){
   for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--){
      string   on = ObjectName(iObj);
      if(StringFind(on, text) == 0)  ObjectDelete(on);
}  }
deletetxt1("Over");

// oscillator-reading version

int twodigits = NormalizeDouble(stoch60[0],0);

//string tds = IntegerToString(twodigits);

int tens = round(twodigits/10);

int ones = twodigits-tens*10; 

string stens, sones;

//Print("tens=",tens);
//Print("ones=",ones);


switch(tens)
{
case  1:   stens=CharToStr(140);
        break;
case  2:   stens=CharToStr(141);
        break;
case  3:   stens=CharToStr(142);
        break;        
case  4:   stens=CharToStr(143);
        break;
case  5:   stens=CharToStr(144);
        break;
case  6:   stens=CharToStr(145);
        break;        
case  7:   stens=CharToStr(146);
        break;                
case  8:   stens=CharToStr(147);
        break;                        
case  9:   stens=CharToStr(148);
        break;                      
  default: stens=CharToStr(139);
      break;
  }
  

switch(ones)
{
case  1:   sones=CharToStr(140);
        break;
case  2:   sones=CharToStr(141);
        break;
case  3:   sones=CharToStr(142);
        break;        
case  4:   sones=CharToStr(143);
        break;
case  5:   sones=CharToStr(144);
        break;
case  6:   sones=CharToStr(145);
        break;        
case  7:   sones=CharToStr(146);
        break;                
case  8:   sones=CharToStr(147);
        break;                        
case  9:   sones=CharToStr(148);
        break;                      
  default: sones=CharToStr(139);
      break;
  }

 
string jointstring=stens+sones;

//if (Close[0]>plus[0] && buy[1]) jointstring=jointstring+CharToStr(66);
//else if (Close[0]>plus[0] && sell[1]) jointstring=jointstring+CharToStr(73);

//if (Close[0]<minus[0] && sell[1]) jointstring=jointstring+CharToStr(66);
//else if (Close[0]<minus[0] && buy[1]) jointstring=jointstring+CharToStr(73);

      ObjectCreate("OverD", OBJ_TEXT, indicator_window, Time[10], 77); 

if (stoch60[0]>88) ObjectSetText("OverD",jointstring,40,"Wingdings",Purple);
else if (stoch60[0]<12)  ObjectSetText("OverD",jointstring,40,"Wingdings",Green);  
else if (ones<6 && tens<=1)  ObjectSetText("OverD",jointstring,40,"Wingdings",Green);
else if (ones>2 && tens==9)  ObjectSetText("OverD",jointstring,40,"Wingdings",Purple);
else ObjectSetText("OverD",jointstring,40,"Wingdings",Brown);