Пример:
Исходный текст:
Код: Выделить всё
function Initialize()
{
IndicatorName = "ConvertEMA";
AddInput("Input", Inputs.Price);
AddParameter("Period", 20);
AddParameter("K", 0.5);
PriceStudy = true;
AddSeries("Upper", DrawAs.Line, Color.LightBlue);
AddSeries("Lower", DrawAs.Line, Color.LightBlue);
}
function Evaluate()
{
// AlfaDirect. 2014. OX
// Convert - Конверт на EMA
if (CurrentIndex < 1)
{
Upper = Input[0] * (1.0 + (double) K / 100.0);
Lower = Input[0] * (1.0 - (double) K / 100.0);
}
else
{
Upper = EMA(Input, Period)[0] * (1.0 + (double) K / 100.0);
Lower = EMA(Input, Period)[0] * (1.0 - (double) K / 100.0);
}
}