Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1095

 
MakarFX:
Give your indicator

Tick indicator.

#property  indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Aqua
double x[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(1);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,x);
   SetIndexDrawBegin(0,0);
   IndicatorDigits(5);
   SetIndexLabel(0,"x");
   SetIndexShift(0,0);
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   double b=MarketInfo(Symbol(),MODE_BID);
   x[0]=b;
   for(int j=ArraySize(x)-1;j>=1;j--){x[j]=x[j-1];}
   return(0);
  }
//+------------------------------------------------------------------+
 
Oleg Bondarev:

The tick indicator.

What does the other one show? Why are they diverging?

How often do they need to be aligned?

 
MakarFX:

What does the second one show? Why do they diverge?

How often do they need to be aligned?

There isn't a second one yet. The principle is the same, ticking, only with a filter. Alignment will be as soon as the pattern appears on the one I posted. Something like wave work (bottom appeared, we align to it, peak appeared, we align to it).

 
Oleg Bondarev:

The second one is not yet available. The principle is the same, tickwise, only with a filter. Alignment will be as the pattern appears on the one I posted. Something like wave work (bottom appears, align to it, peak appears, align to it).

if you combine them into one, you can add a deviation

   x[0]=b+"отклонение";
and depending on where you want to align, the deflection will be (+) or (-).
 
MakarFX:

if they are combined into one, a deviation can be added

and depending on where you want to align, the deflection will be (+) or (-).

The deviation will not be constant. I thought about moving the line with the mouse, but apparently it's not possible. Sad(.

 
Oleg Bondarev:

The deviation will not be constant. Thought about moving the line with the mouse, but apparently you can't do that. Sad(

No way with a mouse...although freelancers can do a mouse deflection adjustment, but for a fee(
Торговые приложения для MetaTrader 5 на заказ
Торговые приложения для MetaTrader 5 на заказ
  • www.mql5.com
Добрый день. Нужен советник на основе индикаторов МА. Вход/выход по пересечению линий. В настройках задаются периоды, сдвиги и методы расчета, метод управления капиталлом, мартнгейл. Код для МТ4/Мт5 Должен работать в тестере. Срок выполнение 2-3 дня Здравствуйте. У меня есть утилита! Она сама выставляет TP и SL мне нужно доработать её что...
 

is called?

Документация по MQL5: Основы языка / Функции / Вызов функции
Документация по MQL5: Основы языка / Функции / Вызов функции
  • www.mql5.com
Если некоторое имя, которое не было описано ранее, появляется в выражении и за ним следует левая круглая скобка, то оно по контексту считается именем некоторой функции. Аргументы (формальные параметры) передаются по значению, т. е. каждое выражение x1, . . . , xn вычисляется и значение передается функции. Порядок вычисления выражений и порядок...
 
MakarFX:
No mice...although freelancers can do a mouse deflection adjustment, but for a fee(

If I was sure that the system would work, I would have ordered it right away.

 
Oleg Bondarev:

The deviation will not be constant. I thought to move the line with the mouse, but apparently it's impossible. Sad(

I did not do it, or rather I did not search for it in the subwindow. In the KB I have laid out an example of clicking on the main window bars and displaying information about the bar - you can look it up

I have made an indicator for experimenting with buttons - I checked if the buttons move the indicator line

#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com/ru/users/igorm"
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot line1
#property indicator_label1  "line1"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
input int shift   = 100;
input int XButton   = 20;
#include <Controls\Button.mqh>
//--- indicator buffers
double         line1Buffer[];
double         Yshift;
CButton button1, button2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   SetIndexBuffer(0, line1Buffer);
   SetIndexEmptyValue(0, 0.0);
   IndicatorDigits(Digits);
   Yshift = 0.0;
   button1.Create(0, "Mybutton1" + (string)rand(), ChartWindowFind(), XButton, 20, 50, 50);
   button1.Text("+");
   button2.Create(0, "Mybutton2" + (string)rand(), ChartWindowFind(), XButton, 70, 50, 100);
   button2.Text("-");
//---
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long& lparam,
                  const double& dparam,
                  const string& sparam
                 )
{
   if(id == CHARTEVENT_OBJECT_CLICK)
   {
      bool isRedraw = false;
      if(sparam == button1.Name())
      {
         Yshift += _Point * (double)shift;
         isRedraw = true;
         button1.Pressed(false);
      }
      if(sparam == button2.Name())
      {
         Yshift -= _Point * (double)shift;
         isRedraw = true;
         button2.Pressed(false);
      }
      if(isRedraw)
      {
         for(int i = ArraySize(line1Buffer) - 1; i >= 0; i--)
            line1Buffer[i] = Close[i] + Yshift;
      }
   }
}
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   int i, limit = prev_calculated == 0 ? rates_total - 1 : rates_total - prev_calculated + 1;
   for(i = limit; i >= 0; i--)
   {
      line1Buffer[i] = close[i] + Yshift;
   }
   return(rates_total);
}
to see that the indicator is moving drop a horizontal line into the indicator subwindow ... Pretty cool thing to do ))))
 
Igor Makanu:

you need mouse click coordinates

There is an easier way, you move the Trendline to the right place and behind it the

something like

        // получаем точки
        string name; double b;
        int i, j=0, n = ObjectsTotal();
        for (i = 0; i<=n; i++)
        {
                name = ObjectName(i);
                if ((ObjectType(name)==OBJ_TREND)&&name==ID)
                {
                        tX[0]=ObjectGet(name, OBJPROP_TIME1); pY[0]=ObjectGet(name, OBJPROP_PRICE1);
                        tX[1]=ObjectGet(name, OBJPROP_TIME2); pY[1]=ObjectGet(name, OBJPROP_PRICE2);
                        break;
                }
        }