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

RangeFilter - трендовый индикатор, фильтр диапазона покупки \ продажи

Добавлено: 30 апр 2020, 10:48
evge
RangeFilter - трендовый индикатор, фильтр диапазона покупки \ продажи
По мотивам: https://ru.tradingview.com/script/vkyFo1sQ/

Параметры:
per - период расчета
mult - множитель для диапазона
showband - отображать канал, если значение параметра не равно 0 (по умолчанию равно 0)

Примеры работы:

RangeFilter-01.png
Индикатор RangeFiler. Параметр showband = 0
RangeFilter-01.png (33.42 КБ) 26386 просмотров

RangeFilter-02.png
Индикатор RangeFiler. Параметр showband = 1
RangeFilter-02.png (38.56 КБ) 26386 просмотров

Для работы понадобится дополнительный, вспомогательный индикатор avrng. Предварительно устанавливаем его.

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

function Initialize()
{
IndicatorName = "avrng";
PriceStudy = false;
AddInput("Input", Inputs.Price);
AddSeries("avrng", DrawAs.Line, Color.Green);
AddParameter("Period", 20);
AddGlobalVariable("K", Types.Double, 0.0);
}

function Evaluate()
{

if (CurrentIndex <= 1)
{
    avrng = Input[0];
    K = 2.0 / (Period + 1.0);
}
else
{
   avrng = (1.0 - K) * avrng[1] + K * Math.Abs(Input[1] - Input[2]);
}

}


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

function Initialize()
{
IndicatorName = "RangeFilter";
PriceStudy = true;
AddInput("Input", Inputs.Price);
AddSeries("RangeFilter", DrawAs.Custom, Color.Black, false);
AddSeries("Buy", DrawAs.Custom, Color.Green);
AddSeries("Sell", DrawAs.Custom, Color.Red);
AddSeries("hband", DrawAs.Custom, Color.Silver);
AddSeries("lband", DrawAs.Custom, Color.Silver);
AddSeries("filt", DrawAs.Custom, Color.Black, false);
AddSeries("upward", DrawAs.Custom, Color.Black, false);
AddSeries("downward", DrawAs.Custom, Color.Black, false);
AddParameter("per", 100, "Sampling Period");
AddParameter("mult", 3, "Range Multiplier");
AddParameter("showband", 0, "Show band > 0");
}

function Evaluate()
{

// evge 26.04.2020 https://alfadirect4.ru

var I = Input;

if (CurrentIndex <= 0)
   {
   filt[0] = I[0];
   upward[0] = 0;
   downward[0] = 0;
   return;
   }

var avrng = MY.avrng(I, per);
var smrng = EMA(avrng, (per * 2) - 1)[0] * mult;

filt[0] = I[0] > filt[1] ? ((I[0] - smrng) < filt[1] ? filt[1] : (I[0] - smrng)) : ((I[0] + smrng) > filt[1] ? filt[1] : (I[0] + smrng));

upward[0] = filt[0] > filt[1] ? upward[1] + 1 : filt[0] < filt[1] ? 0 : upward[1];
downward[0] = filt[0] < filt[1] ? downward[1] + 1 : filt[0] > filt[1] ? 0 : downward[1];

Buy[0] = filt[0];
Sell[0] = filt[0];

if (upward[0] > 0)
   {
   Buy.DrawLine();
   }
   else
if (downward[0] > 0)
   {
   Sell.DrawLine();
   }
   
if (showband > 0)
   {
   hband[0] = filt[0] + smrng;
   lband[0] = filt[0] - smrng;
   hband.DrawChannel(Buy);
   lband.DrawChannel(Sell);
   }
   
}


Скачать индикатор:

RangeFilter.zip
(65.31 КБ) 1033 скачивания

Re: RangeFilter - трендовый индикатор, фильтр диапазона покупки \ продажи

Добавлено: 10 окт 2023, 00:55
Mandarin84
на текущий момент для меня это главный индикатор моей стратегии
период/показатель ставлю 7 , незнаю почему, меньше шумов и больше прибыльных сделок

Re: RangeFilter - трендовый индикатор, фильтр диапазона покупки \ продажи

Добавлено: 20 окт 2023, 08:34
smb
Этот индикатор можно оптимизировать? Какие бы условия для покупки или продажи в конструкторе не ставил, все не то получается.