Вот код
Код: Выделить всё
function Initialize()
{
IndicatorName = "ExtremumsLast";
PriceStudy = true;
AddInput("Input", Inputs.Candle);
AddSeries("H", DrawAs.Custom, Color.Green);
AddSeries("L", DrawAs.Custom, Color.Red);
AddParameter("Period", 6);
}
function Evaluate()
{
//evge 07.02.2016 http://alfadirect4.ru
var High = Input.High[Period];
var Low = Input.Low[Period];
var HC = true;
var LC = true;
for (var x = 1; x <= Period; x++) {
if (Input.High[Period + x] > High || Input.High[Period - x] > High) HC = false;
if (Input.Low[Period + x] < Low || Input.Low[Period - x] < Low) LC = false;
if (!LC && !HC) break;
} //x
if (HC) H[0] = Input.High[Period]; else H[0] = H[1];
if (LC) L[0] = Input.Low[Period]; else L[0] = L[1];
H.DrawCircle();
L.DrawCircle();
}
Изменение только в строках
Код: Выделить всё
if (HC) H[Period] = Input.High[Period];
if (LC) L[Period] = Input.Low[Period];
заменены на
Код: Выделить всё
if (HC) H[0] = Input.High[Period]; else H[0] = H[1];
if (LC) L[0] = Input.Low[Period]; else L[0] = L[1];
Вот что будет на выходе