azzx_donchian_1_0

0 Views
0 Downloads
0 Favorites
azzx_donchian_1_0
// ---------------------------------------------------------------------------
//  Êëàññè÷åñêèé êàíàë Äîí÷èàíà - ïî ýêñòðåìóìàì çà N äíåé.
//
//  Áóôåðû èíäèêàòîðà:
//  0 - Âåðõíÿÿ ãðàíèöà.
//  1 - Íèæíÿÿ ãðàíèöà.
//  2 - Ñåðåäèíà êàíàëà.
// ---------------------------------------------------------------------------

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1  Blue
#property indicator_color2  Blue
#property indicator_color3  DarkViolet
#property indicator_style3  STYLE_DOT

// Äëèíà ðàññìàòðèâàåìîé èñòîðèè.
extern int HISTORY_DEPTH = 24;

// Áóôåðû èíäèêàòîðà.
double buf_up[], buf_dn[], buf_md[];

// Èíèöèàëèçàöèÿ.
int init() {
  IndicatorShortName(StringConcatenate(
    "AZZX - DONCHIAN CHANNEL v1.0 (", HISTORY_DEPTH, ")"));
  IndicatorDigits(Digits);
    
  SetIndexBuffer(0, buf_up);
  SetIndexBuffer(1, buf_dn);
  SetIndexBuffer(2, buf_md);
  
  SetIndexLabel(0, "UPPER BOUND");
  SetIndexLabel(1, "LOWER BOUND");
  SetIndexLabel(2, "MIDDLE LINE");
  
  return(0);
}

// Ãëàâíûé öèêë.
int start() {
  int i;
  
  for(i = Bars - IndicatorCounted() - 1; i >= 0; i--) {
    buf_up[i] = High[iHighest(NULL, 0, MODE_HIGH, HISTORY_DEPTH, i)];
    buf_dn[i] = Low [iLowest (NULL, 0, MODE_LOW,  HISTORY_DEPTH, i)];
    buf_md[i] = 0.5 * (buf_up[i] + buf_dn[i]);
  }
  
  return(0);
}

Comments