Каталог файлов форума

Список вложений в сообщениях, оставленных на этой конференции.

Все файлы форума: 1233

Добавлено: evge » 21 мар 2016, 19:46

Тема: SixLevels - автоматическое формирование уровней

Текст сообщения:

SixLevels автоматически формирует по локальным экстремумам горизонтальные уровни. Всего формируется 3 уровня по максимумам и 3 уровня по минимумам.

Входящие параметры

Width - толщина линии уровня
Period - количество баров для поиска экстремумов
Scan - количество баров сканируемой истории
SkipBars - количество игнорируемых последних баров (отступ справа)

Примеры работы

SixLevels-01.png
SixLevels-01.png (32.51 КБ) 27229 просмотров

SixLevels-03.png
SixLevels-03.png (39.91 КБ) 27211 просмотров

SixLevels-04.png
Пример с 2 индикаторами SixLevels. Разные параметры и толщина линии уровня.
SixLevels-04.png (33.34 КБ) 27184 просмотра

SixLevels.zip
(1.15 КБ) 1270 скачиваний


Исходный код

Код: Выделить всё

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;
}

}


Скачать исходный текст

SixLevels-02.png
SixLevels-02.png (31.94 КБ) 27229 просмотров