Код: Выделить всё
function Initialize()
{
IndicatorName = "TSI";
PriceStudy = false;
AddInput("I", Inputs.Candle);
AddSeries("TSI", DrawAs.Line, Color.Red);
AddSeries("MA", DrawAs.Line, Color.Black);
AddParameter("First_R", 20, 1);
AddParameter("Second_S", 30, 1);
AddParameter("Period_MA", 10, 1);
AddGlobalVariable("SUM", Types.Double, 0.0);
}
function Evaluate()
{
// evge 27.10.2017 http://alfadirect4.ru
if (CurrentIndex >= Math.Max(Math.Max(First_R, Second_S), Period_MA))
{
TSI[0] = 100 * EMA(EMA(MOMENTUM(I.Close, 1), First_R), Second_S)[0] / EMA(EMA(MY.MomentumR(I.Close, 1), First_R), Second_S);
SUM += TSI[0] - TSI[Period_MA];
MA[0] = SUM / Period_MA;
} else
{
TSI[0] = 0;
MA[0] = 0;
}
}