Входящие параметры
Width - толщина линии уровня
Period - количество баров для поиска экстремумов
Scan - количество баров сканируемой истории
SkipBars - количество игнорируемых последних баров (отступ справа)
Примеры работы
Исходный код
Код: Выделить всё
function Initialize()
{
   IndicatorName = "SixLevels";   
   PriceStudy = true;
   AddInput("Input", Inputs.Candle);   
   AddSeries("H", DrawAs.Custom, Color.Green);   
   AddSeries("L", DrawAs.Custom, Color.Red);
   AddSeries("H1", DrawAs.Custom, Color.Green);     
   AddSeries("L1", DrawAs.Custom, Color.Red);     
   AddSeries("H2", DrawAs.Custom, Color.Green);     
   AddSeries("L2", DrawAs.Custom, Color.Red);     
   AddSeries("H3", DrawAs.Custom, Color.Green);     
   AddSeries("L3", DrawAs.Custom, Color.Red);     
    AddLevel(0, Color.Red, LineStyles.DashSmall, 1, "L1");
    AddLevel(0, Color.Red, LineStyles.DashSmall, 1, "L2");
    AddLevel(0, Color.Red, LineStyles.DashSmall, 1, "L3");
    AddLevel(0, Color.Green, LineStyles.DashSmall, 1, "H1");
    AddLevel(0, Color.Green, LineStyles.DashSmall, 1, "H2");
    AddLevel(0, Color.Green, LineStyles.DashSmall, 1, "H3");
   AddParameter("Width", 1);
   AddParameter("Period", 15);
   AddParameter("Scan", 300, 1);
   AddParameter("SkipBars", 30);
}
function Evaluate()
{
// evge 21.03.2016, http://alfadirect4.ru
var High = Input.High[Period];
var Low = Input.Low[Period];
var HC = true; 
var LC = true; 
for (var x = 0; x < Period; x++) { 
if (HC) if (Input.High[Period * 2 - x] > High || Input.High[x] > High) HC = false;
if (LC) if (Input.Low[Period * 2 - x] < Low || Input.Low[x] < Low) LC = false;
if (!LC && !HC) break;
} //x
if (HC) H[Period] = Input.High[Period];
if (LC) L[Period] = Input.Low[Period];
H.DrawCircle();
L.DrawCircle();
if (CurrentIndex < 1) {
Levels[0].Level = 0; Levels[1].Level = 0; Levels[2].Level = 0;
Levels[3].Level = 0; Levels[4].Level = 0; Levels[5].Level = 0;
Levels[0].Width = (int)Width; Levels[1].Width = (int)Width;
Levels[2].Width = (int)Width; Levels[3].Width = (int)Width;
Levels[4].Width = (int)Width; Levels[5].Width = (int)Width;
}
if (CurrentIndex == MaxIndex) 
for (var x = 0 + SkipBars; x < Scan; x++) {
   if (L[x] > 0 && L1[0] == 0) { L1[0]= L[x]; Levels[0].Level = L[x]; } else
   if (L[x] > 0 && L2[0] == 0) { L2[0]= L[x]; Levels[1].Level = L[x]; } else
   if (L[x] > 0 && L3[0] == 0) { L3[0]= L[x]; Levels[2].Level = L[x]; }
   if (H[x] > 0 && H1[0] == 0) { H1[0]= H[x]; Levels[3].Level = H[x]; } else
   if (H[x] > 0 && H2[0] == 0) { H2[0]= H[x]; Levels[4].Level = H[x]; } else
   if (H[x] > 0 && H3[0] == 0) { H3[0]= H[x]; Levels[5].Level = H[x]; }
   if (L3[0] > 0 && H3[0] > 0) break;
}
}
Скачать исходный текст
 Изображения (1057)
 Изображения (1057) Архивы (82)
 Архивы (82) Текстовые файлы (9)
 Текстовые файлы (9) Документы (7)
 Документы (7) Скрипты Альфа-Директ 4 (30)
 Скрипты Альфа-Директ 4 (30)