Линии вместо стрелок - страница 2

 
Anna Furmanova:

Добавила два буфера. Изменений нет.

Не надо ни чего добавлять

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_width1 1
#property indicator_color2 Lime
#property indicator_width2 1
#property indicator_color3 Red
#property indicator_width3 1
#property indicator_color4 Lime
#property indicator_width4 1

extern int SignalGap = 4;
extern int ShowBars = 500;
extern bool repaint = false;

int dist=24;

double b1[];
double b2[];
double b3[];
double b4[];

int init()  {
   
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,218);
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexArrow(3,217);
   
   SetIndexBuffer(0,b1);
   SetIndexBuffer(1,b2);
   SetIndexBuffer(2,b3);
   SetIndexBuffer(3,b4);
      
   return(0);
}

int start() {
   
   int i,hhb,llb;
   
   if (ShowBars >= Bars) ShowBars = Bars;
   
   for (i=0;i<ShowBars;i++)   {
   
      b1[i]=EMPTY_VALUE;
      b2[i]=EMPTY_VALUE;
      b3[i]=EMPTY_VALUE;
      b4[i]=EMPTY_VALUE;
      
      if(repaint)
      {
        hhb = iHighest(Symbol(),0,MODE_HIGH,dist,i-dist/2);
        llb = iLowest(Symbol(),0,MODE_LOW,dist,i-dist/2);
      } else
      {
        hhb = iHighest(Symbol(),0,MODE_HIGH,dist,i);
        llb = iLowest(Symbol(),0,MODE_LOW,dist,i);
      }

      
      if (i==hhb)
         b3[i]=High[hhb]+SignalGap*Point;
      
      if (i==llb)
         b4[i]=Low[llb]-SignalGap*Point;
         
         b1[i]=High[hhb];//+SignalGap*Point;
         b2[i]=Low[llb];//-SignalGap*Point;
   
   }
   return(0);
}
 
0000
 
Alekseu Fedotov:

Не надо ни чего добавлять

А нужно горизонтальные линии, вместо стрелок

 

Может такой вариант устроит

//+------------------------------------------------------------------+
//|                                                Price_Channel.mq4 |
//|                                            Copyright 2015, Vinin |
//|                                             http://vinin.ucoz.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, Vinin"
#property link      "http://vinin.ucoz.ru"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_plots   5
//--- plot UP
#property indicator_label1  "UP"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot Midle
#property indicator_label2  "Midle"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- plot DN
#property indicator_label3  "DN"
#property indicator_type3   DRAW_LINE
#property indicator_color3  clrRed
#property indicator_style3  STYLE_SOLID
#property indicator_width3  1
//--- plot UP
#property indicator_label4  "UP1"
#property indicator_type4   DRAW_LINE
#property indicator_color4  clrRed
#property indicator_style4  STYLE_SOLID
#property indicator_width4  1
//--- plot DN
#property indicator_label5  "DN1"
#property indicator_type5   DRAW_LINE
#property indicator_color5  clrRed
#property indicator_style5  STYLE_SOLID
#property indicator_width5  1


//--- input parameters
input int      CalcBar=25;
input int Shift=1;

//--- indicator buffers
double         UPBuffer[];
double         MidleBuffer[];
double         DNBuffer[];
double         UP1Buffer[];
double         DN1Buffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,UPBuffer);
   SetIndexBuffer(1,MidleBuffer);
   SetIndexBuffer(2,DNBuffer);
   SetIndexBuffer(3,UP1Buffer);
   SetIndexBuffer(4,DN1Buffer);
   
   SetIndexShift(0,Shift);
   SetIndexShift(1,Shift);
   SetIndexShift(2,Shift);
   SetIndexShift(3,Shift);
   SetIndexShift(4,Shift);

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   ArraySetAsSeries(high, true);
   ArraySetAsSeries(low, true);
//---
   int limit=rates_total-prev_calculated;
   if (limit>1) limit=rates_total-CalcBar-1;
   
   for (int i=limit;i>=0;i--)
   {
      int pos=ArrayMaximum(high, CalcBar, i);
      UPBuffer[i]=high[pos];
      pos=ArrayMinimum(low,CalcBar, i);
      DNBuffer[i]=low[pos];
      MidleBuffer[i]=(UPBuffer[i]+DNBuffer[i])*0.5;
      UP1Buffer[i]=(UPBuffer[i]+MidleBuffer[i])*0.5;
      DN1Buffer[i]=(DNBuffer[i]+MidleBuffer[i])*0.5;
   }
   
   
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Anna Furmanova:  А нужно горизонтальные линии, вместо стрелок

Сколько горизонтальных линий должно одновременно существовать на экране? если ограниченное количество - порядка 10 - надо на каждую завести буфер. Линию можно задавать начальной и конечной точкой. Для этого очистить буферный массив и в два элемента массива, соответствующие времени начала и конца, поместить одну и ту же цену. Если линий очень много - использовать объекты: ObjectCreate("ИмяЭтойЛинии", OBJ_HLINE, 0, 0, Цена)

Причина обращения: