Прошу помощи поправить индикатор HLC

 

Здравствуйте всем.

Есть у меня индикатор HLC BARS, отображает на баре только цену закрытия.

//+------------------------------------------------------------------+
//|                                                     HLC BARS.mq4 |
//|                                    Copyright © 2008, FOREXflash. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, FOREXflash Software Corp."
#property link      "http://www.metaquotes.net"


#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Lime
#property indicator_color2 Lime
#property indicator_color3 Red
#property indicator_color4 Yellow
#property indicator_color7 Red
#property indicator_color8 Lime

#property indicator_width1 6
#property indicator_width2 6
#property indicator_width3 6
#property indicator_width4 6




//---- bar buffer
double Buffer1[];
double Buffer2[];
double Buffer5[];
double Buffer6[];
double Buffer7[];
double Buffer8[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
//---- indicators  

SetIndexStyle( 0, DRAW_HISTOGRAM );
SetIndexBuffer( 0, Buffer5 );
SetIndexStyle( 1, DRAW_HISTOGRAM );
SetIndexBuffer( 1, Buffer6 );
SetIndexStyle( 2, DRAW_HISTOGRAM );
SetIndexBuffer( 2, Buffer7 );
SetIndexStyle( 3, DRAW_HISTOGRAM );
SetIndexBuffer( 3, Buffer8 );
SetIndexStyle( 6, DRAW_HISTOGRAM );
SetIndexBuffer( 6, Buffer1 );
SetIndexStyle( 7, DRAW_HISTOGRAM );
SetIndexBuffer( 7, Buffer2 );
//---- 
IndicatorShortName( "HLC BARS" );
//---- 

return( 0 );
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
{

int i, CountedBars, Limit;
double Indicator1, Indicator2, Indicator3;
CountedBars = IndicatorCounted();
if (Bars <= 15) return( 0 );
if (CountedBars < 1)
{
for (i = 1;(i <= 15);i = i+1) 
{    

    Buffer5[(Bars - i)] = 0.0;
    Buffer7[(Bars - i)] = 0.0;
    Buffer6[(Bars - i)] = 0.0;
    Buffer8[(Bars - i)] = 0.0;
  }
}

//----

if (CountedBars > 0)  Limit = (Bars - CountedBars);
if (CountedBars == 0) Limit = ((Bars - 15) - 1);
for (i = Limit;(i >= 0);i = i-1) 
{  

  

  Buffer5[i] = 0;
  Buffer7[i] = 0;
  Buffer6[i] = 0;
  Buffer8[i] = 0;
  
//----
  
  if ((Close[i]>Open[i])) 
  {

  Buffer5[i] =MathMax( Close[i]+2*Point, Close[i] );
  Buffer6[i] =MathMin( Close[i]+2*Point, Close[i] );
  Buffer1[i] =Low[i];
  Buffer2[i] =High[i];
  } 
  {
  if ((Close[i]<Open[i])) 
  {

  Buffer7[i] =MathMax( Close[i]+2*Point, Close[i] );
  Buffer8[i] =MathMin( Close[i]+2*Point, Close[i] );
  Buffer2[i] =Low[i];
  Buffer1[i] =High[i];

  }
 }
}
return( 0 );
}
//+------------------------------------------------------------------+

На инструменте ES работает штатно:


А вот dj euro stoxx 50:


полоса цены закрытия стала прямоугольником, соответственно читаемость никакая. Может кто наведёт на путь исправления?

Спасибо.

 

Сейчас включал DAX, он нормально показывает. Там цена как на es с дробной частью. Может быть проблема с целочисленными значениями цены.

 
doitagainforme:

Здравствуйте всем.

Есть у меня индикатор HLC BARS, отображает на баре только цену закрытия.


На инструменте ES работает штатно:

А вот dj euro stoxx 50:

полоса цены закрытия стала прямоугольником, соответственно читаемость никакая. Может кто наведёт на путь исправления?

Спасибо.


Вообще индикатор показывает не просто "цены закрытия" а красит бары в соответствии с условиями.

Можно реализовать так

//+------------------------------------------------------------------+
//|                                                     HLC BARS.mq4 |
//|                                    Copyright © 2008, FOREXflash. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, FOREXflash Software Corp."
#property link      "http://www.metaquotes.net"


#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Lime
#property indicator_color2 Lime
#property indicator_color3 Red
#property indicator_color4 Yellow
#property indicator_color7 Red
#property indicator_color8 Lime

#property indicator_width1 6
#property indicator_width2 6
#property indicator_width3 6
#property indicator_width4 6

//---- bar buffer
double Buffer1[];
double Buffer2[];
double Buffer5[];
double Buffer6[];
double Buffer7[];
double Buffer8[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init(){
//---- indicators  
SetIndexBuffer( 0, Buffer5 );
SetIndexBuffer( 1, Buffer6 );
SetIndexBuffer( 2, Buffer7 );
SetIndexBuffer( 3, Buffer8 );
SetIndexBuffer( 6, Buffer1 );
SetIndexBuffer( 7, Buffer2 );
for(int i=0;i<8;i++){
SetIndexEmptyValue(i,0.0); //все буферы == 0,0
SetIndexStyle(i, DRAW_HISTOGRAM); //все буферы DRAW_HISTOGRAM
}
IndicatorShortName( "HLC BARS" );
//---- 
return( 0 );
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit(){
    return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start(){
int count =IndicatorCounted();
if (Bars < 4*WindowBarsPerChart()){ Alert("Маловато истории, ждемс!"); count = 0;}
//----
for (int i = Bars - count-1;i >= 0;i--){  
  Buffer5[i] = 0;
  Buffer7[i] = 0;
  Buffer6[i] = 0;
  Buffer8[i] = 0;
  if ((Close[i]>Open[i])) {
    Buffer5[i] =Close[i]+(WindowPriceMax(0)-WindowPriceMin(0))/5000 ;
    Buffer6[i] =Close[i] ;
    Buffer1[i] =Low[i];
    Buffer2[i] =High[i];
  } 
  if ((Close[i]<Open[i])) {
    Buffer7[i] =Close[i]+(WindowPriceMax(0)-WindowPriceMin(0))/5000;
    Buffer8[i] =Close[i] ;
    Buffer2[i] =Low[i];
    Buffer1[i] =High[i];
  }
}
WindowRedraw();
return( 0 );
}
//+------------------------------------------------------------------+
 

costy_ помогло! :)


Спасибо! кидайте адрес, вышлю пиво и рыбу.