Страница 1 из 1

Медиана

Добавлено: 22 фев 2019, 17:42
BugsDigger

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

function Initialize()
{
 IndicatorName = "Median";
 PriceStudy = true;
 AddInput("Input", Inputs.Price);
 AddSeries("Median", DrawAs.Line, Color.Red);

 AddParameter("Period", 5);
 AddGlobalVariable("Buf", Types.DoubleList);
}

function Evaluate()
{
 Buf.Add(Input[0]);
 if(Buf.Count>Period) Buf.RemoveAt(0);

 List<double> tmp = new List<double>(Buf);
 tmp.Sort();
 Median[0]=tmp[tmp.Count/2];
}