Re: Как в скрипте стратегии добавить на график индикатор?
Добавлено: 24 июн 2017, 18:15
Провокационный вопрос
Неофициальный форум клиентского терминала Альфа-Инвестиции (Альфа-Директ 4). Обсуждение терминала, обмен опытом, разработка скриптов индикаторов и стратегий.
https://www.alfadirect4.ru/
Код: Выделить всё
function Initialize()
{
IndicatorName = "My.Levels";
PriceStudy = true;
AddInput("Input", Inputs.Candle);
AddSeries("LVL1", DrawAs.Custom, Color.Yellow);
AddSeries("LVL2", DrawAs.Custom, Color.Yellow);
AddSeries("LVL3", DrawAs.Custom, Color.Yellow);
AddSeries("LVL4", DrawAs.Custom, Color.Yellow);
AddSeries("LVL5", DrawAs.Custom, Color.Yellow);
AddSeries("LVL6", DrawAs.Custom, Color.Yellow);
AddSeries("LVL7", DrawAs.Custom, Color.Yellow);
AddSeries("LVL8", DrawAs.Custom, Color.Yellow);
AddLevel(0, Color.Yellow, LineStyles.DashSmall, 1, "LVL1");
AddLevel(0, Color.Yellow, LineStyles.DashSmall, 1, "LVL2");
AddLevel(0, Color.Yellow, LineStyles.DashSmall, 1, "LVL3");
AddLevel(0, Color.Yellow, LineStyles.DashSmall, 1, "LVL4");
AddLevel(0, Color.Yellow, LineStyles.DashSmall, 1, "LVL5");
AddLevel(0, Color.Yellow, LineStyles.DashSmall, 1, "LVL6");
AddLevel(0, Color.Yellow, LineStyles.DashSmall, 1, "LVL7");
AddLevel(0, Color.Yellow, LineStyles.DashSmall, 1, "LVL8");
AddParameter("LV1", 0);
AddParameter("LV2", 0);
AddParameter("LV3", 0);
AddParameter("LV4", 0);
AddParameter("LV5", 0);
AddParameter("LV6", 0);
AddParameter("LV7", 0);
AddParameter("LV8", 0);
}
function Evaluate()
{
if (CurrentIndex != 0)
{
Levels[1].Level = LV1;
Levels[1].Level = LV2;
Levels[2].Level = LV3;
Levels[3].Level = LV4;
Levels[4].Level = LV5;
Levels[5].Level = LV6;
Levels[5].Level = LV7;
Levels[5].Level = LV8;
}
}
Код: Выделить всё
AddParameter("LV1", 1, "LV1", 1); // Уровень 1
AddParameter("LV2", 1, "LV2", 1); // Уровень 2 и т.д
Код: Выделить всё
AddChartIndicator("MY.Levels", new Dictionary <string, string> {{"LVL1", "LV1"}, {"LVL2", "LV2"}, {"LVL3", "LV3"}, {"LVL4", "LV4"}, {"LVL5", "LV5"}, {"LVL6", "LV6"}, {"LVL7", "LV7"}, {"LVL8", "LV8"}} );
Код: Выделить всё
AddChartIndicator("MY.Levels", new Dictionary <string, string> {{"LV1", "LV1"}, {"LV2", "LV2"}, {"LV3", "LV3"}, {"LV4", "LV4"}, {"LV5", "LV5"}, {"LV6", "LV6"}, {"LV7", "LV7"}, {"LV8", "LV8"}} );
Код: Выделить всё
Levels[1].Level = LV1;
Levels[1].Level = LV2;
Levels[2].Level = LV3;
Levels[3].Level = LV4;
Levels[4].Level = LV5;
Levels[5].Level = LV6;
Levels[5].Level = LV7;
Levels[5].Level = LV8;