Ussault писал(а):Подскажите, пожалуйста, что нужно поменять в коде для того, чтобы отображались цены уровней?
Код с отображением цен уровней
Код: Выделить всё
function Initialize()
{
   IndicatorName = "LevelPivot";
   PriceStudy = true;
   AddInput("Input", Inputs.Candle);
   AddParameter("TF", 100, 5);
   AddSeries("LevelPivot",  DrawAs.Line, Color.Gray);
// Global
  AddGlobalVariable("Min",  Types.Double, 0.0);
  AddGlobalVariable("Max",  Types.Double, 0.0);
  AddGlobalVariable("Hi",  Types.Double, 0.0);
  AddGlobalVariable("Lo",  Types.Double, 0.0);
  AddGlobalVariable("Cl",  Types.Double, 0.0);
// Серии для отображения цен
   AddSeries("L1",  DrawAs.Custom, Color.LightGreen);
   AddSeries("L2",  DrawAs.Custom, Color.LightGreen);
   AddSeries("L3",  DrawAs.Custom, Color.LightGreen);
   AddSeries("L4",  DrawAs.Custom, Color.LightGreen);
   AddSeries("L5",  DrawAs.Custom, Color.Coral);
   AddSeries("L6",  DrawAs.Custom, Color.Coral);
   AddSeries("L7",  DrawAs.Custom, Color.Coral);
// Уровни
  AddLevel(0, Color.LightGreen, LineStyles.DashBig, 1, "LevelPivot");
  AddLevel(0, Color.LightGreen, LineStyles.Dot, 1,  "LevelPivot");
  AddLevel(0, Color.LightGreen, LineStyles.Dot, 1, "LevelPivot");
  AddLevel(0, Color.LightGreen, LineStyles.Dot, 1, "LevelPivot");
  AddLevel(0, Color.Coral, LineStyles.Dot, 1, "LevelPivot");
  AddLevel(0, Color.Coral, LineStyles.Dot, 1, "LevelPivot");
  AddLevel(0, Color.Coral, LineStyles.Dot, 1, "LevelPivot");
}
function Evaluate()
{
// AlfaDirect. 2015. OX
// LevelPivot - уровни разворота для текущего (последнего) дня
if (CurrentIndex < 1)
{
     Cl = Input.Close[0];
     Hi = Input.High[0];
     Lo = Input.Low[0];
   Max = Input.High[0];
   Min = Input.Low[0];
}
else if (BarTime() == AsTime(10, 0, 0))
{
     Cl = Input.Close[-1];
     Hi = Max;
     Lo = Min;
   Max = Input.High[0];
   Min = Input.Low[0];
}
else
{
   if (Input.High[0] > Max )
      Max = Input.High[0];
   if (Input.Low[0] < Min )
      Min = Input.Low[0];
}
if (CurrentIndex == MaxIndex)
{
var Pivot = (Hi+Lo+Cl)/3;
Levels[0].Level = Pivot;
// Resistance
Levels[1].Level = Pivot * 2 - Lo;
Levels[2].Level = Pivot + Hi - Lo;
Levels[3].Level = Hi + 2*(Pivot-Lo);
// Support
Levels[4].Level = Pivot * 2 - Hi;
Levels[5].Level = Pivot - Hi + Lo;
Levels[6].Level = Lo - 2*(Hi-Pivot);
L1 = Levels[0].Level;
L2 = Levels[1].Level;
L3 = Levels[2].Level;
L4 = Levels[3].Level;
L5 = Levels[4].Level;
L6 = Levels[5].Level;
L7 = Levels[6].Level;
}
}
Скачать индикатор
 Изображения (1057)
 Изображения (1057) Архивы (82)
 Архивы (82) Текстовые файлы (9)
 Текстовые файлы (9) Документы (7)
 Документы (7) Скрипты Альфа-Директ 4 (30)
 Скрипты Альфа-Директ 4 (30)