Нужен простой индикатор.

 

Добрый день! К сожалению не силён в программировании поэтому прошу помочь кто знает как сделать.

Требуется индикатор который бы окрашивал бары в зависимости от положения АО Вильямса относительно

нулевой линии. Т.е. если АО ниже нулевой - бары одного цвета, соответственно выше - бары другого.

Буду очень благодарен.

 

Берете в директории с индикаторами AO находите строчку

if(current>prev) up=true;
if(current<prev) up=false;

меняйте условие на

if(current>0) up=true;
if(current<0) up=false;
 
GVladimir >>:

Берете в директории с индикаторами AO находите строчку

меняйте условие на


Спасибо, но это немного не то. То что вы предложили окрашивает бары АО а я бы хотел чтобы окрашивались бары ценовые.

 
Alligator писал(а) >>

Спасибо, но это немного не то. То что вы предложили окрашивает бары АО а я бы хотел чтобы окрашивались бары ценовые.

Тогда надо делать на основе Heiken Ashi, просто условия для раскрашивания использовать свои

 
Вот переделал из CodeBase:
//+------------------------------------------------------------------+ 
//| prusax_v2.mq4                                                    |
//| 2008 modified by zIG                                             |
//+------------------------------------------------------------------+ 
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 White
#property indicator_color2 White
#property indicator_color3 Red
#property indicator_color4 Red
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2
//---- buffers 
double BufferUP[];
double BufferDN[];
double BufferUP1[];
double BufferDN1[];
//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int init()
  {
   string short_name;
//---- indicator line 
   IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,BufferUP);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,BufferUP1);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexBuffer(2,BufferDN);
   SetIndexStyle(3,DRAW_HISTOGRAM);
   SetIndexBuffer(3,BufferDN1);
   SetIndexDrawBegin(0,10);
   SetIndexDrawBegin(1,10);
   SetIndexDrawBegin(2,10);
   SetIndexDrawBegin(3,10);
//---- 
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
   for(i=Bars-counted_bars-1;i>=0;i--)
   
     {double AO=iAO(NULL,0,i);

         
         if(AO>0)
           {
            BufferUP[i]   =Close[i];
            BufferUP1[i]  =Open[i];
            BufferDN[i]    =0.0;
            BufferDN1[i]   =0.0;
           }
         if(AO<0)
              {
               BufferUP[i]   =0.0;
               BufferUP1[i]  =0.0;
               BufferDN[i]    =Open[i];
               BufferDN1[i]   =Close[i];
              }
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+ 
 
Donatom >>:
Вот переделал из CodeBase:

Геннадий, огромное спасибо! ТО ЧТО НУЖНО!

 

Геннадий, ещё одна просьба.В данном индикаторе окрашиваются тела свечей или баров.А возможно ли сделать чтобы тени также были окрашены в один цвет с барами?

Примерно как здесь https://www.mql5.com/ru/code/7554

 
Или как здесь https://www.mql5.com/ru/code/8534/page3#14211
 

На основе Heiken:

//+------------------------------------------------------------------+
//|                                                  Heiken AO.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Red
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Red
#property indicator_color5 Green
#property indicator_color6 Green
#property indicator_color7 Green
#property indicator_color8 Green
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 2
#property indicator_width4 2
#property indicator_width5 1
#property indicator_width6 1
#property indicator_width7 2
#property indicator_width8 2

//----
extern string s   = "False окраска по уровню 0, True окраска по направлению AO";
extern bool Okr = false;
extern color color1 = Red;
extern color color2 = Red;
extern color color3 = Red;
extern color color4 = Red;
extern color color5 = Green;
extern color color6 = Green;
extern color color7 = Green;
extern color color8 = Green;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double ExtMapBuffer7[];
double ExtMapBuffer8[];
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM, 0, 1, color1);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM, 0, 1, color2);
   SetIndexBuffer(1, ExtMapBuffer2);
   SetIndexStyle(2,DRAW_HISTOGRAM, 0, 2, color3);
   SetIndexBuffer(2, ExtMapBuffer3);
   SetIndexStyle(3,DRAW_HISTOGRAM, 0, 2, color4);
   SetIndexBuffer(3, ExtMapBuffer4);
   SetIndexStyle(4,DRAW_HISTOGRAM, 0, 1, color5);
   SetIndexBuffer(4, ExtMapBuffer5);
   SetIndexStyle(5,DRAW_HISTOGRAM, 0, 1, color6);
   SetIndexBuffer(5, ExtMapBuffer6);
   SetIndexStyle(6,DRAW_HISTOGRAM, 0, 2, color7);
   SetIndexBuffer(6, ExtMapBuffer7);
   SetIndexStyle(7,DRAW_HISTOGRAM, 0, 2, color8);
   SetIndexBuffer(7, ExtMapBuffer8);
//----
   SetIndexDrawBegin(0,10);
   SetIndexDrawBegin(1,10);
   SetIndexDrawBegin(2,10);
   SetIndexDrawBegin(3,10);
   SetIndexDrawBegin(4,10);
   SetIndexDrawBegin(5,10);
   SetIndexDrawBegin(6,10);
   SetIndexDrawBegin(7,10);
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexBuffer(5,ExtMapBuffer6);
   SetIndexBuffer(6,ExtMapBuffer7);
   SetIndexBuffer(7,ExtMapBuffer8);
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   double haOpen, haHigh, haLow, haClose;
   int i,counted_bars=IndicatorCounted();
   for(i=Bars-counted_bars-1;i>=0;i--)

     {
     double AO1=iAO(NULL,0,i);
     double AO2=iAO(NULL,0,i+1);

      haOpen=Open[i];
      haClose=Close[i];
      haHigh=High[i];
      haLow=Low[i];
      if (Okr)
       { if (AO1<AO2) 
        {
         ExtMapBuffer1[i]=haLow;
         ExtMapBuffer2[i]=haHigh;
         ExtMapBuffer3[i]=haOpen;
         ExtMapBuffer4[i]=haClose;
         ExtMapBuffer5[i]=0.0;
         ExtMapBuffer6[i]=0.0;
         ExtMapBuffer7[i]=0.0;
         ExtMapBuffer8[i]=0.0;
         }
         
      if (AO1>=AO2)
         {
         ExtMapBuffer1[i]=0.0;
         ExtMapBuffer2[i]=0.0;
         ExtMapBuffer3[i]=0.0;
         ExtMapBuffer4[i]=0.0;
         ExtMapBuffer5[i]=haLow;
         ExtMapBuffer6[i]=haHigh;
         ExtMapBuffer7[i]=haOpen;
         ExtMapBuffer8[i]=haClose;
         }}
         if (!Okr)
         {
      if (AO1<0) 
        {
         ExtMapBuffer1[i]=haLow;
         ExtMapBuffer2[i]=haHigh;
         ExtMapBuffer3[i]=haOpen;
         ExtMapBuffer4[i]=haClose;
         ExtMapBuffer5[i]=0.0;
         ExtMapBuffer6[i]=0.0;
         ExtMapBuffer7[i]=0.0;
         ExtMapBuffer8[i]=0.0;
         }
         
      if (AO1>=0)
         {
         ExtMapBuffer1[i]=0.0;
         ExtMapBuffer2[i]=0.0;
         ExtMapBuffer3[i]=0.0;
         ExtMapBuffer4[i]=0.0;
         ExtMapBuffer5[i]=haLow;
         ExtMapBuffer6[i]=haHigh;
         ExtMapBuffer7[i]=haOpen;
         ExtMapBuffer8[i]=haClose;
         }}
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Проще пока не умею.

 
Только понижательные бары можно настроить.Посмотри пожалуйста код ещё.
 
В предыдущем посте поменял код. Теперь можно переключать окраску либо относительно уровня 0 - АО, либо в зависимости от направления (понижение - повышение) АО.
Причина обращения: