← К каталогу
Исходный код · ID 5165

SuperTrend Zone PRO

supertrendzone_pro_mt4.mq5
Вы автор или правообладатель?

Сообщите нам, если считаете, что материал размещён без разрешения.

Краткий обзор

О программе

SuperTrend Zone PRO — это индикатор для MetaTrader 5, который строит аналитические линии SuperTrend с визуальными зонами вокруг них. Индикатор рассчитывает краткосрочную и долгосрочную версии SuperTrend на основе среднего истинного диапазона (ATR) и отображает их в виде цветных линий на графике цены.

Индикатор выделяет зоны BUY и SELL, ограниченные линиями SuperTrend, с возможностью заливки и настройки прозрачности. На графике отображаются ценовые метки справа, текстовые подписи зон и стрелки сигналов при входе цены в зону. Долгосрочные линии SuperTrend отрисовываются пунктиром отдельно от основных.

Встроенная система уведомлений позволяет получать алерты при наступлении условий BUY ZONE или SELL ZONE. Настройки включают возможность срабатывания алертов по закрытой свече или в реальном времени. Все визуальные элементы — цвета, толщина линий, размер шрифта меток — полностью настраиваются пользователем.

Настройки программы

НастройкаОписание
InpFactor Основной множитель фактора для расчёта краткосрочного SuperTrend
InpATRLength Период ATR для краткосрочного расчёта SuperTrend
InpZoneWidth Ширина зоны в виде множителя ATR вокруг линии SuperTrend
InpShowLongTerm Отображает или скрывает долгосрочные линии SuperTrend
InpLongFactorMultiplier Множитель фактора для расчёта долгосрочного SuperTrend
InpLongATRMultiplier Множитель периода ATR для расчёта долгосрочного SuperTrend
InpShowZoneFill Отображает или скрывает заливку зон между линией SuperTrend и границей зоны
InpZoneFillTransparency Прозрачность заливки зоны: 0 — сплошная, 100 — полностью прозрачная
InpShowPriceTags Отображает или скрывает ценовые метки справа на графике
InpShowZoneText Отображает или скрывает текстовые подписи BUY ZONE и SELL ZONE
InpShowSignals Отображает или скрывает стрелки сигналов BUY и SELL
InpAlerts Включает или отключает систему уведомлений о событиях зон
InpAlertOnClosedBar При включении уведомления срабатывают по закрытой свече, а не в реальном времени
InpBuyColor Цвет линий и меток для BUY-сигналов
InpSellColor Цвет линий и меток для SELL-сигналов
InpLongBuyColor Цвет долгосрочных линий BUY
InpLongSellColor Цвет долгосрочных линий SELL
InpMainLineWidth Толщина основных линий SuperTrend
InpZoneLineWidth Толщина линий границ зон BUY и SELL
InpLongLineWidth Толщина линий долгосрочного SuperTrend
InpTagFontSize Размер шрифта ценовых меток на графике

Поиск по коду файла

#property strict
#property indicator_chart_window
#property indicator_buffers 12

input double InpFactor              = 4.00;
input int    InpATRLength           = 100;
input double InpZoneWidth           = 1.00;

input bool   InpShowLongTerm        = true;
input double InpLongFactorMultiplier= 3.0;
input int    InpLongATRMultiplier   = 3;

input bool   InpShowZoneFill        = true;
input int    InpZoneFillTransparency= 75;   // 0=solid, 100=transparent

input bool   InpShowPriceTags       = true;
input bool   InpShowZoneText        = true;
input bool   InpShowSignals         = true;

input bool   InpAlerts              = true;
input bool   InpAlertOnClosedBar    = true;

input color  InpBuyColor            = clrDodgerBlue;
input color  InpSellColor           = clrCrimson;
input color  InpLongBuyColor        = clrRoyalBlue;
input color  InpLongSellColor       = clrDeepPink;

input int    InpMainLineWidth       = 2;
input int    InpZoneLineWidth       = 2;
input int    InpLongLineWidth       = 1;
input int    InpTagFontSize         = 9;

double BuyST[], SellST[];
double BuyZone[], SellZone[];
double LongBuy[], LongSell[];
double BuyArrow[], SellArrow[];

double BuyFillA[], BuyFillB[];
double SellFillA[], SellFillB[];

double AtrShort[], AtrLong[];
double STShort[], STLong[];
double ZoneUp[], ZoneDown[];
int    DirShort[], DirLong[];

string PREFIX = "STZPRO_";

int OnInit()
{
      // код доступен только после оплаты
   }

void CalcATR(const double &high[], const double &low[],
             const double &close[], int rates, int period,
             double &atr[])
{
   ArrayResize(atr,rates);
   ArraySetAsSeries(atr,true);

   double tr[];
   ArrayResize(tr,rates);
   ArraySetAsSeries(tr,true);

   for(int i=rates-1;i>=0;i--)
   {
      if(i==rates-1)
         tr[i]=high[i]-low[i];
      else
      {
         double a=high[i]-low[i];
         double b=MathAbs(high[i]-close[i+1]);
         double c=MathAbs(low[i]-close[i+1]);
         tr[i]=MathMax(a,MathMax(b,c));
      }
      atr[i]=0.0;
   }

   if(rates < period+1) return;

   int seed=rates-period;
   double sum=0.0;
   for(int j=rates-1;j>=seed;j--) sum+=tr[j];
   atr[seed]=sum/period;

   for(int i=seed-1;i>=0;i--)
      atr[i]=((atr[i+1]*(period-1.0))+tr[i])/period;
}

void CalcST(const double &high[], const double &low[],
            const double &close[], int rates, int period, double factor,
            const double &atr[], double &st[], int &dir[],
            double &zu[], double &zd[], bool makeZone)
{
   ArrayResize(st,rates);  ArraySetAsSeries(st,true);
   ArrayResize(dir,rates); ArraySetAsSeries(dir,true);
   ArrayResize(zu,rates);  ArraySetAsSeries(zu,true);
   ArrayResize(zd,rates);  ArraySetAsSeries(zd,true);

   double fu[],fl[];
   ArrayResize(fu,rates); ArrayResize(fl,rates);
   ArraySetAsSeries(fu,true); ArraySetAsSeries(fl,true);

   for(int i=rates-1;i>=0;i--)
   {
      st[i]=EMPTY_VALUE;
      dir[i]=0;
      zu[i]=EMPTY_VALUE;
      zd[i]=EMPTY_VALUE;
      fu[i]=EMPTY_VALUE;
      fl[i]=EMPTY_VALUE;
   }

   int first=rates-period;
   if(first<0) first=0;

   double hl2=(high[first]+low[first])*0.5;
   fu[first]=hl2+factor*atr[first];
   fl[first]=hl2-factor*atr[first];

   if(close[first] <= fu[first])
   {
      dir[first]=-1;
      st[first]=fl[first];
   }
   else
   {
      dir[first]=1;
      st[first]=fu[first];
   }

   if(makeZone)
   {
      if(dir[first]<0) zu[first]=st[first]+atr[first]*InpZoneWidth;
      else if(dir[first]>0) zd[first]=st[first]-atr[first]*InpZoneWidth;
   }

   for(int i=first-1;i>=0;i--)
   {
      hl2=(high[i]+low[i])*0.5;
      double bu=hl2+factor*atr[i];
      double bl=hl2-factor*atr[i];

      if(bu<fu[i+1] || close[i+1]>fu[i+1]) fu[i]=bu;
      else fu[i]=fu[i+1];

      if(bl>fl[i+1] || close[i+1]<fl[i+1]) fl[i]=bl;
      else fl[i]=fl[i+1];

      if(st[i+1]==fu[i+1])
      {
         if(close[i]<=fu[i])
         {
            st[i]=fu[i];
            dir[i]=1;
         }
         else
         {
            st[i]=fl[i];

Показано первые 50% кода (символов: 9158)