Download MetaTrader 5

Awesome Oscillator modification HELP needed

To add comments, please log in or register
Black_Jack822
57
Black_Jack822  
Hi all, I'm trying to make modified AO indicator and this is a part that I'm working on right now, I'm still baby in coding so I need your help:)
Is it possible to make the rectangle in bottom left corner change color like the histogram ?? I don't even care about the histogram in separate window at all, just the rectangle.
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Black
#property  indicator_color2  YellowGreen
#property  indicator_color3  Red


//---- indicator buffers
double     ExtBuffer0[];
double     ExtBuffer1[];
double     ExtBuffer2[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
      ObjectCreate("1",OBJ_LABEL,0,0,0,0,0);
      ObjectSet("1",OBJPROP_CORNER, 2);
      ObjectSet("1",OBJPROP_XDISTANCE,0);
      ObjectSet("1",OBJPROP_YDISTANCE,0);
      
//---- drawing settings
   SetIndexStyle(0,DRAW_NONE);
//------------------------------- 
  
   SetIndexStyle(1,DRAW_HISTOGRAM);
  
//-------------------------------
   
   SetIndexStyle(2,DRAW_HISTOGRAM);
   
 
//---- 3 indicator buffers mapping
   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,ExtBuffer1);
   SetIndexBuffer(2,ExtBuffer2);

//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Awesome Oscillator                                               |
//+------------------------------------------------------------------+
int start()
  {
   double prev,current;
//---- last counted bar will be recounted

   int counted_bars=IndicatorCounted();
   if(counted_bars < 0)  return(-1);
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
   if(counted_bars==0) limit-=1+1;

//---- macd
   for(int i=0; i<limit; i++)
      ExtBuffer0[i]=iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA(NULL,0,34,0,MODE_SMA,PRICE_MEDIAN,i);
//---- dispatch values between 2 buffers
   bool up=true;
   for(i=limit-1; i>=0; i--)
     {
      current=ExtBuffer0[i];
      prev=ExtBuffer0[i+1];
      if(current>prev) up=true;
      if(current<prev) up=false;
      if(!up)
        {
         ExtBuffer2[i]=current;
         ExtBuffer1[i]=0.0;
        }
      else
        {
         ExtBuffer1[i]=current;
         ExtBuffer2[i]=0.0;
        }
     }
//---- done
// ---------------------------------------------------------------------
//--- Draw signal
  
ObjectSetText("1", CharToStr(249), 60, "Wingdings");

//---- done
   return(0);
  }
//+------------------------------------------------------------------+
Black_Jack822
57
Black_Jack822  
I've done it :)Topic closed.
To add comments, please log in or register