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

AlertPrice - алерт пересечения уровня

Добавлено: 08 июл 2017, 22:11
Kurono
Автор: ox
Ссылка на кеш гугла

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

function Initialize()
{
   IndicatorName = "AlertPrice";
   PriceStudy = true;   
   AddInput("Input", Inputs.Price);
    AddSeries("P", DrawAs.Custom, Color.Red);   
   AddLevel(1, Color.Red, LineStyles.Solid, 1, "P");

    AddParameter("Price", 0.0);

   AddGlobalVariable("S", Types.Boolean, false);
}

function Evaluate()
{
//evge 28.01.2016

if (MaxIndex != CurrentIndex) return; //to the future

if (Price == 0) return;

P = Price;
Levels[0].Level = Price;

if (!S) {
if  ((Input[0] > Price) && (Input[1] <= Price))
   {
   ShowMessage("Пересечение ВВЕРХ " + (double)Price);
   S = true;
   }
if ((Input[0] < Price) && (Input[1] >= Price))
   {
   ShowMessage("Пересечение ВНИЗ " + (double)Price);
   S = true;
   }
}

//Сбрасываем флаг сообщения если ниже или выше уровня
if (S && (Input[1] > Price) && (Input[0] > Price) ) S = false;
if (S && (Input[1] < Price) && (Input[0] < Price) ) S = false;

}


Пример: сообщение при пересечении уровня 210