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

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

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

Добавлено: Владимир » 02 апр 2017, 21:51

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

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

Добрый день!
A.Lemzhin писал(а):
Добрый день. Можно выложить версию, где поиск уровней проходит для каждого бара?

Добавил вывод данных в лог в коде

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

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];
   LogData ("L1 - "  + Convert.ToString(L[x]) , IndicatorName); } else
   if (L[x] > 0 && L2[0] == 0) { L2[0]= L[x]; Levels[1].Level = L[x];
   LogData ("L2 - "  + Convert.ToString(L[x]) , IndicatorName); } else
   if (L[x] > 0 && L3[0] == 0) { L3[0]= L[x]; Levels[2].Level = L[x];
   LogData ("L3 - "  + Convert.ToString(L[x]) , IndicatorName);}

   if (H[x] > 0 && H1[0] == 0) { H1[0]= H[x]; Levels[3].Level = H[x];
   LogData ("H1 - "  + Convert.ToString(H[x]) , IndicatorName); } else
   if (H[x] > 0 && H2[0] == 0) { H2[0]= H[x]; Levels[4].Level = H[x];
   LogData ("H2 - "  + Convert.ToString(H[x]) , IndicatorName); } else
   if (H[x] > 0 && H3[0] == 0) { H3[0]= H[x]; Levels[5].Level = H[x];
   LogData ("H3 - "  + Convert.ToString(H[x]) , IndicatorName); }

   if (L3[0] > 0 && H3[0] > 0) break;
}

}

Если вы будете двигать график, то индикатор будет перерисовывать уровни и в логе вы увидите ответ на свой вопрос!
Только есть один нюанс, для просмотра обновлений каждый раз придется закрывать и снова открывать файл лога.
Вложения
SixLevels.jpg
SixLevels.log
(888 байт) 1605 скачиваний