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

wyattspivots_v2.1_w_toggle.mq5

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

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

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

О программе

Индикатор MetaTrader 4 для отображения уровней пивотов, промежуточных точек, зон и границ на графике. Рассчитывает ключевые уровни сопротивления, поддержки и центральную точку на основе данных цен выбранного таймфрейма. Поддерживает отображение исторических и будущих периодов с возможностью сдвига по часовому поясу.

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

НастройкаОписание
iCountPeriods Количество периодов — Определяет, сколько исторических периодов уровней отображается на графике.
iTimePeriod Таймфрейм — Выбирает временной интервал для расчёта и построения уровней пивотов.
iShiftHours Сдвиг часов — Задаёт смещение в часах от времени закрытия дня брокера для корректировки расчётов дневных уровней.
iPlotPivots Отображать пивоты — Включает или отключает построение линий уровней сопротивления и поддержки на графике.
iPlotPivotFutures Отображать будущие пивоты — Включает или отключает построение уровней для текущего незавершённого периода.
iPlotPivotLabels Отображать метки пивотов — Включает или отключает текстовые подписи уровней на правой стороне графика.
iPlotPivotPrices Отображать цены пивотов — Включает или отключает отображение числовых значений уровней слева от линий.
iPlotPivotStyles Стиль линий пивотов — Задаёт стиль отображения линий уровней пивотов.
iPlotPivotWidths Толщина линий пивотов — Задаёт толщину линий уровней пивотов.
iPlotPivotColorRes Цвет сопротивления — Определяет цвет линий уровней сопротивления.
iPlotPivotColorPP Центральная точка — Определяет цвет линии центральной пивот-точки.
iPlotPivotColorSup Цвет поддержки — Определяет цвет линий уровней поддержки.
iPlotMidpoints Отображать промежуточные точки — Включает или отключает построение линий промежуточных уровней между пивотами.
iPlotMidpointStyles Стиль линий промежуточных точек — Задаёт стиль отображения линий промежуточных уровней.
iPlotMidpointWidths Толщина линий промежуточных точек — Задаёт толщину линий промежуточных уровней.
iPlotMidpointColorM35 Цвет M3–M5 — Определяет цвет линий промежуточных уровней M3, M4 и M5.
iPlotMidpointColorM02 Цвет M0–M2 — Определяет цвет линий промежуточных уровней M0, M1 и M2.
iPlotZones Отображать зоны — Включает или отключает построение цветных зон между определёнными промежуточными уровнями.
iPlotBuyZoneColor Цвет зоны покупки — Определяет цвет зоны, соответствующей диапазону между промежуточными уровнями M1 и S2.
iPlotSellZoneColor Цвет зоны продажи — Определяет цвет зоны, соответствующей диапазону между промежуточными уровнями M4 и R2.
iPlotBorders Отображать границы — Включает или отключает построение вертикальных линий начала и конца периода.
iPlotBorderStyles Стиль границ — Задаёт стиль отображения линий границ периода.
iPlotBorderWidths Толщина линий границ — Задаёт толщину линий границ периода.
iPlotBorderColors Цвет границ — Определяет цвет линий границ периода.
iPushNotifications_AllPivotsMidpoints Уведомления всех уровней — Отправляет push-уведомление с расчётами всех пивотов и промежуточных точек при начале нового периода.
iPushNotifications_TouchPP Касание центральной точки — Отправляет уведомление, когда цена приближается к центральной пивот-точке.
iPushNotifications_TouchR1S1 Касание R1/S1 — Отправляет уведомление, когда цена приближается к уровням R1 или S1.
iPushNotifications_TouchR2S2 Касание R2/S2 — Отправляет уведомление, когда цена приближается к уровням R2 или S2.
iPushNotifications_TouchR3S3 Касание R3/S3 — Отправляет уведомление, когда цена приближается к уровням R3 или S3.
iPushNotifications_TouchM2M3 Касание M2/M3 — Отправляет уведомление, когда цена приближается к уровням M2 или M3.
iPushNotifications_TouchM1M4 Касание M1/M4 — Отправляет уведомление, когда цена приближается к уровням M1 или M4.
iPushNotifications_TouchM0M5 Касание M0/M5 — Отправляет уведомление, когда цена приближается к уровням M0 или M5.
iPushNotifications_TouchToleranceInDigits Допуск касания — Задаёт допуск в знаках графика, при котором считается, что цена коснулась уровня.
Toggle_Button Переключатель кнопки — Параметр для настройки текста или состояния переключающей кнопки на графике.
btn_show Показать кнопку — Включает или отключает отображение кнопки на графике для скрытия и отображения объектов.
btn_pressed Текст кнопки нажата — Текст, отображаемый на кнопке в нажатом состоянии.
btn_unpressed Текст кнопки отпущена — Текст, отображаемый на кнопке в отпущенном состоянии.
btn_offset_x Смещение кнопки X — Горизонтальное смещение кнопки от левого нижнего угла графика.
btn_offset_y Смещение кнопки Y — Вертикальное смещение кнопки от левого нижнего угла графика.
btn_font_size Размер шрифта кнопки — Размер шрифта текста на кнопке.
btn_width Ширина кнопки — Ширина кнопки в пикселях.
btn_height Высота кнопки — Высота кнопки в пикселях.
btn_font_clr Цвет шрифта кнопки — Определяет цвет текста на кнопке.
btn_bg_color Фон кнопки — Определяет цвет фона кнопки.
btn_border_clr Цвет границы кнопки — Определяет цвет рамки кнопки.
Получить полный код

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

#property indicator_chart_window
#property indicator_buffers   0

extern int              iCountPeriods         = 2;
extern ENUM_TIMEFRAMES  iTimePeriod           = PERIOD_D1;
extern int              iShiftHours           = 0;

extern bool             iPlotPivots           = true;
extern bool             iPlotPivotFutures     = true;
extern bool             iPlotPivotLabels      = true;
extern bool             iPlotPivotPrices      = true;
extern ENUM_LINE_STYLE  iPlotPivotStyles      = STYLE_SOLID;
extern int              iPlotPivotWidths      = 2;
extern color            iPlotPivotColorRes    = clrRed;
extern color            iPlotPivotColorPP     = clrBlack;
extern color            iPlotPivotColorSup    = clrGreen;

extern bool             iPlotMidpoints        = true;
extern ENUM_LINE_STYLE  iPlotMidpointStyles   = STYLE_DASH;
extern int              iPlotMidpointWidths   = 1;
extern color            iPlotMidpointColorM35 = clrRed;
extern color            iPlotMidpointColorM02 = clrGreen;

extern bool             iPlotZones            = true;
extern color            iPlotBuyZoneColor     = clrLightSeaGreen;
extern color            iPlotSellZoneColor    = clrLightSalmon;

extern bool             iPlotBorders          = false;
extern ENUM_LINE_STYLE  iPlotBorderStyles     = STYLE_SOLID;
extern int              iPlotBorderWidths     = 1;
extern color            iPlotBorderColors     = clrBlack;

extern bool             iPushNotifications_AllPivotsMidpoints     = False;
extern bool             iPushNotifications_TouchPP                = False;
extern bool             iPushNotifications_TouchR1S1              = False;
extern bool             iPushNotifications_TouchR2S2              = False;
extern bool             iPushNotifications_TouchR3S3              = False;
extern bool             iPushNotifications_TouchM2M3              = False;
extern bool             iPushNotifications_TouchM1M4              = False;
extern bool             iPushNotifications_TouchM0M5              = False;
extern int              iPushNotifications_TouchToleranceInDigits = 20;

extern string Toggle_Button = "";
extern bool btn_show = 0;
extern string btn_pressed = "WP Show";
extern string btn_unpressed = "WP Hide";
extern int btn_offset_x = 10;
extern int btn_offset_y = 20;
extern int btn_font_size = 10;
extern int btn_width = 65;
extern int btn_height = 20;
extern color btn_font_clr = clrBlack;
extern color btn_bg_color = clrGray;
extern color btn_border_clr = clrWhiteSmoke;

#define  MAX_NUM_NOTIFICATION_QUEUE       10
#define  MAX_TIMER_EVENT_ELAPSED_IN_SECS  10

string   gPeriod = "";
int      gRealTimePeriod = 0;
datetime gPrevTimePivot = 0;
double   gPrevTouchPrice = 0.0;
double   gTouchToleranceDecimal = 0.0;
int      gNumNotificationQueue = 0;
string   gNotificationQueue[MAX_NUM_NOTIFICATION_QUEUE] = {NULL};

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

int deinit()
{

   DeleteAllObjects();
   ObjectDelete("WP_btn");
   EventKillTimer();
   return(0);
}

void OnTimer()
{
   int error = 0;
   int i = 0;

   if (gNumNotificationQueue > 0 && gNumNotificationQueue < MAX_NUM_NOTIFICATION_QUEUE)
   {

      for (i = 0; i < gNumNotificationQueue; i++)
      {

         if (StringLen(gNotificationQueue[i]) > 0)
         {

            if (SendNotification(gNotificationQueue[i]) == false)
            {

               error = GetLastError();
               Print("<= Error sending notification => ", error);
               return;
            }
            else
            {

               gNotificationQueue[i] = "";
               return;
            }
         }
      }  // end of notification queue (for loop)

      if (error == 0)
      {
         gNumNotificationQueue = 0;
      }
   }  // end of notification buffer check (if statement)
   else if (gNumNotificationQueue >= MAX_NUM_NOTIFICATION_QUEUE)
   {

      for (i = 0; i < gNumNotificationQueue; i++)
      {
         gNotificationQueue[i] = "";
      }
      gNumNotificationQueue = 0;
   }

   return;
}

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

int SendPushNotifications(void)
{
   int error = 0;
   double pivP = 0.0;
   double res1 = 0.0;
   double res2 = 0.0;
   double res3 = 0.0;
   double sup1 = 0.0;
   double sup2 = 0.0;
   double sup3 = 0.0;
   double mid0 = 0.0;
   double mid1 = 0.0;
   double mid2 = 0.0;
   double mid3 = 0.0;
   double mid4 = 0.0;
   double mid5 = 0.0;
   string msg = "";
   string pivMsg = "";
   string midMsg = "";
   int startBarShift = 0;
   int endBarShift = 0;
   datetime currBarTime = 0;
   datetime endTimeShift = 0;
   double currBarPrice = 0.0;

   if (iTimePeriod == PERIOD_D1 && iShiftHours != 0)
   {   

      error = GetShiftInfo(0, startBarShift, endBarShift, currBarTime, endTimeShift);
   }
   else
   {

      currBarTime = iTime(NULL, iTimePeriod, 0);
      if (currBarTime == 0)
      {

         error = GetLastError();
         Print("<= Error getting current bar time => ", error);
         return error;
      }
   }

   currBarPrice = Bid;
   if (currBarPrice == 0)
   {

      error = GetLastError();
      Print("<= Error getting current bid price => ", error);
      return error;
   }

   error = GetPivotPoints(iTimePeriod, 1, pivP, res1, res2, res3, sup1, sup2, sup3, mid0, mid1, mid2, mid3, mid4, mid5);
   if (error != 0)
   {
      return error;
   }

   if (iPlotPivots)
   {
      pivMsg = StringConcatenate(
               ", ", gPeriod, "R3: ", DoubleToStr(res3, Digits), 
               ", ", gPeriod, "R2: ", DoubleToStr(res2, Digits), 
               ", ", gPeriod, "R1: ", DoubleToStr(res1, Digits), 
               ", ", gPeriod, "PP: ", DoubleToStr(pivP, Digits), 
               ", ", gPeriod, "S1: ", DoubleToStr(sup1, Digits), 
               ", ", gPeriod, "S2: ", DoubleToStr(sup2, Digits), 
               ", ", gPeriod, "S3: ", DoubleToStr(sup3, Digits));
   }

   if (iPlotMidpoints)
   {     
      midMsg = StringConcatenate(
               ", ", gPeriod, "M5: ", DoubleToStr(mid5, Digits), 
               ", ", gPeriod, "M4: ", DoubleToStr(mid4, Digits), 
               ", ", gPeriod, "M3: ", DoubleToStr(mid3, Digits), 
               ", ", gPeriod, "M2: ", DoubleToStr(mid2, Digits), 
               ", ", gPeriod, "M1: ", DoubleToStr(mid1, Digits), 
               ", ", gPeriod, "M0: ", DoubleToStr(mid0, Digits));
   }

   if (iPushNotifications_AllPivotsMidpoints == True &&
         (gPrevTimePivot == 0 || gPrevTimePivot != currBarTime))   // initial program start or a new time period has begun
   {

      gPrevTimePivot = currBarTime;

      Print(Symbol() + pivMsg + midMsg);
      if (gNumNotificationQueue < MAX_NUM_NOTIFICATION_QUEUE)
      {
         gNotificationQueue[gNumNotificationQueue] = StringConcatenate(Symbol() + pivMsg + midMsg);
         gNumNotificationQueue++;
      }
   }

   SendPushNotifications_Touch(iPushNotifications_TouchPP, "PP", pivP, currBarPrice);
   SendPushNotifications_Touch(iPushNotifications_TouchR1S1, "R1", res1, currBarPrice);
   SendPushNotifications_Touch(iPushNotifications_TouchR1S1, "S1", sup1, currBarPrice);
   SendPushNotifications_Touch(iPushNotifications_TouchR2S2, "R2", res2, currBarPrice);
   SendPushNotifications_Touch(iPushNotifications_TouchR2S2, "S2", sup2, currBarPrice);
   SendPushNotifications_Touch(iPushNotifications_TouchR3S3, "R3", res3, currBarPrice);
   SendPushNotifications_Touch(iPushNotifications_TouchR3S3, "S3", sup3, currBarPrice);

   SendPushNotifications_Touch(iPushNotifications_TouchM2M3, "M2", mid2, currBarPrice);
   SendPushNotifications_Touch(iPushNotifications_TouchM2M3, "M3", mid3, currBarPrice);
   SendPushNotifications_Touch(iPushNotifications_TouchM1M4, "M1", mid1, currBarPrice);
   SendPushNotifications_Touch(iPushNotifications_TouchM1M4, "M4", mid4, currBarPrice);
   SendPushNotifications_Touch(iPushNotifications_TouchM0M5, "M0", mid0, currBarPrice);
   SendPushNotifications_Touch(iPushNotifications_TouchM0M5, "M5", mid5, currBarPrice);

   return error;
}

int SendPushNotifications_Touch( bool FeatureEnabled,
                                 string LevelStr,
                                 double TargetPrice,
                                 double CurrBarPrice)
{
   int sent = 0;
   string msg = "";

   if (gPrevTouchPrice < 0.0000001)
   {
      gPrevTouchPrice = CurrBarPrice;
   }

   if (FeatureEnabled == True &&
       MathAbs(TargetPrice - gPrevTouchPrice) > 0.0000001 &&                 // price has not already touched before (double compare)
         (MathAbs(TargetPrice - CurrBarPrice) <= gTouchToleranceDecimal ||   // current price is close to target price -or-
          (gPrevTouchPrice < TargetPrice && TargetPrice < CurrBarPrice) ||   // target price is between last touch and current price (gaps)
          (gPrevTouchPrice > TargetPrice && TargetPrice > CurrBarPrice)))
   {

      gPrevTouchPrice = TargetPrice;

      msg = StringConcatenate(Symbol(), ", Price touched ", gPeriod, LevelStr, " at ", DoubleToStr(TargetPrice, Digits));
      Print(msg);
      if (gNumNotificationQueue < MAX_NUM_NOTIFICATION_QUEUE)
      {
         gNotificationQueue[gNumNotificationQueue] = StringConcatenate(msg);
         gNumNotificationQueue++;
      }

      sent = 1;
   }

   return sent;
}

int LevelsDraw(   int      Shift,
                  datetime TimeStartObj, 
                  datetime TimeEndObj, 
                  string   PeriodStr,
                  bool     IsFuture)
{
   int error = 0;
   double pivP = 0.0;         // Pivot Levels
   double res1 = 0.0;
   double res2 = 0.0;
   double res3 = 0.0;
   double sup1 = 0.0;
   double sup2 = 0.0;
   double sup3 = 0.0;
   double mid0 = 0.0;
   double mid1 = 0.0;
   double mid2 = 0.0;
   double mid3 = 0.0;
   double mid4 = 0.0;
   double mid5 = 0.0;

   error = GetPivotPoints(iTimePeriod, Shift, pivP, res1, res2, res3, sup1, sup2, sup3, mid0, mid1, mid2, mid3, mid4, mid5);
   if (error != 0)
   {
      return error;
   }

   if (iPlotZones)
   {
      PlotRectangle(0, PeriodStr + "BZ_" + Shift, 0, TimeStartObj, mid1, TimeEndObj, sup2, iPlotBuyZoneColor);    
      PlotRectangle(0, PeriodStr + "SZ_" + Shift, 0, TimeStartObj, mid4, TimeEndObj, res2, iPlotSellZoneColor);
   }

   if (iPlotPivots)
   {                                 

      PlotTrend(0, PeriodStr + "R3_T" + Shift, 0, TimeStartObj, res3, TimeEndObj, res3, iPlotPivotColorRes, iPlotPivotStyles, iPlotPivotWidths);     
      PlotTrend(0, PeriodStr + "R2_T" + Shift, 0, TimeStartObj, res2, TimeEndObj, res2, iPlotPivotColorRes, iPlotPivotStyles, iPlotPivotWidths);     
      PlotTrend(0, PeriodStr + "R1_T" + Shift, 0, TimeStartObj, res1, TimeEndObj, res1, iPlotPivotColorRes, iPlotPivotStyles, iPlotPivotWidths);     
      PlotTrend(0, PeriodStr + "PP_T" + Shift, 0, TimeStartObj, pivP, TimeEndObj, pivP, iPlotPivotColorPP, iPlotPivotStyles, iPlotPivotWidths);     
      PlotTrend(0, PeriodStr + "S1_T" + Shift, 0, TimeStartObj, sup1, TimeEndObj, sup1, iPlotPivotColorSup, iPlotPivotStyles, iPlotPivotWidths);     
      PlotTrend(0, PeriodStr + "S2_T" + Shift, 0, TimeStartObj, sup2, TimeEndObj, sup2, iPlotPivotColorSup, iPlotPivotStyles, iPlotPivotWidths);     
      PlotTrend(0, PeriodStr + "S3_T" + Shift, 0, TimeStartObj, sup3, TimeEndObj, sup3, iPlotPivotColorSup, iPlotPivotStyles, iPlotPivotWidths);

      if (iPlotPivotLabels)
      {
         PlotText(0, PeriodStr + "R3_L" + Shift, 0, TimeEndObj, res3, PeriodStr + "R3", "Arial", 8, iPlotPivotColorRes, ANCHOR_RIGHT_UPPER);
         PlotText(0, PeriodStr + "R2_L" + Shift, 0, TimeEndObj, res2, PeriodStr + "R2", "Arial", 8, iPlotPivotColorRes, ANCHOR_RIGHT_UPPER);
         PlotText(0, PeriodStr + "R1_L" + Shift, 0, TimeEndObj, res1, PeriodStr + "R1", "Arial", 8, iPlotPivotColorRes, ANCHOR_RIGHT_UPPER);
         PlotText(0, PeriodStr + "PP_L" + Shift, 0, TimeEndObj, pivP, PeriodStr + "PP", "Arial", 8, iPlotPivotColorPP, ANCHOR_RIGHT_UPPER);
         PlotText(0, PeriodStr + "S1_L" + Shift, 0, TimeEndObj, sup1, PeriodStr + "S1", "Arial", 8, iPlotPivotColorSup, ANCHOR_RIGHT_UPPER);
         PlotText(0, PeriodStr + "S2_L" + Shift, 0, TimeEndObj, sup2, PeriodStr + "S2", "Arial", 8, iPlotPivotColorSup, ANCHOR_RIGHT_UPPER);
         PlotText(0, PeriodStr + "S3_L" + Shift, 0, TimeEndObj, sup3, PeriodStr + "S3", "Arial", 8, iPlotPivotColorSup, ANCHOR_RIGHT_UPPER);
      }    

      if (iPlotPivotPrices)
      {
         PlotText(0, PeriodStr + "R3_P" + Shift, 0, TimeStartObj, res3, DoubleToString(res3, Digits), "Arial", 8, iPlotPivotColorRes, ANCHOR_LEFT_UPPER);
         PlotText(0, PeriodStr + "R2_P" + Shift, 0, TimeStartObj, res2, DoubleToString(res2, Digits), "Arial", 8, iPlotPivotColorRes, ANCHOR_LEFT_UPPER);
         PlotText(0, PeriodStr + "R1_P" + Shift, 0, TimeStartObj, res1, DoubleToString(res1, Digits), "Arial", 8, iPlotPivotColorRes, ANCHOR_LEFT_UPPER);
         PlotText(0, PeriodStr + "PP_P" + Shift, 0, TimeStartObj, pivP, DoubleToString(pivP, Digits), "Arial", 8, iPlotPivotColorPP, ANCHOR_LEFT_UPPER);
         PlotText(0, PeriodStr + "S1_P" + Shift, 0, TimeStartObj, sup1, DoubleToString(sup1, Digits), "Arial", 8, iPlotPivotColorSup, ANCHOR_LEFT_UPPER);
         PlotText(0, PeriodStr + "S2_P" + Shift, 0, TimeStartObj, sup2, DoubleToString(sup2, Digits), "Arial", 8, iPlotPivotColorSup, ANCHOR_LEFT_UPPER);
         PlotText(0, PeriodStr + "S3_P" + Shift, 0, TimeStartObj, sup3, DoubleToString(sup3, Digits), "Arial", 8, iPlotPivotColorSup, ANCHOR_LEFT_UPPER);
      }
   }    

   if (iPlotMidpoints)
   {

      PlotTrend(0, PeriodStr + "M0_T" + Shift, 0, TimeStartObj, mid0, TimeEndObj, mid0, iPlotMidpointColorM02, iPlotMidpointStyles, iPlotMidpointWidths);     
      PlotTrend(0, PeriodStr + "M1_T" + Shift, 0, TimeStartObj, mid1, TimeEndObj, mid1, iPlotMidpointColorM02, iPlotMidpointStyles, iPlotMidpointWidths);     
      PlotTrend(0, PeriodStr + "M2_T" + Shift, 0, TimeStartObj

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

Открыть по тарифу

Купите тариф с пакетом открытий или войдите, если тариф уже есть. Открытый файл останется в вашем кабинете навсегда.

Разовая покупка файла

На этой странице откроется полный исходный код файла вместо ознакомительного фрагмента.

Чтобы оформить заказ, введите email и перейдите к оплате.

Стоимость полного кода
2 473,10₽ ≈ $30.23