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

 
How do I know there is noOBJ_RECTANGLE on N bars?
 
neverness:

Has anything really changed in MT5?

There is no such thing in either mt4 or mt5.

In mt5 there is even a bug with displaying the separator in the current period, on times over H2

 
Ghabo:
How do I know that there is noOBJ_RECTANGLE on N bars?
Try it this way maybe?
  int n = Bars(Symbol(), PERIOD_CURRENT, ObjectGetInteger(0,"Rectangle",OBJPROP_TIME,1), TimeCurrent());
  Print(n);
 
Vitaly Muzichenko:

There is no such thing in either mt4 or mt5.

In mt5 there is even an error with showing the separator in the current period, on times above H2

Finally I saw the only "constructive answer" to my question in this whole "discussion".

As for the errors, they are present on all separator-weeks in the current (last) frame on both MT4 and MT5.

Everywhere in the last week separator MT4/MT5 draws the separator 7 days instead of 5.

But that is not the point. The errors have always been and will always be. All this may be corrected if there is a program code for drawing delimiters.

It's not the mistakes that surprise me, it's something else entirely.

Has nobody thought of writing a program for drawing delimiters in the predicted area during all the time of MT4/MT5 existence?

After all, the program is the simplest one.

All you need to know is position of the last divider and "solution" of time along X axis (i.e. what time interval takes 1 pixel).

And so far no one has ever ???

Now that really surprises me.

Again I'll have to do everything myself.

 
Igor Makanu:

It's not complicated, but you don't seem to understand how indicators work in MT and what their advantages are

You are probably right.

There is a mathematical anecdote:

A mathematician is asked: How do you boil water in a kettle?

The mathematician answers: Get an empty kettle, pour water into it, put the kettle on the cooker, turn on the cooker, and wait for the water to boil.

- OK. But what if the kettle is already full? - the mathematician asks.

- Pour the water out of the kettle, and solve the problem in the way above. - answers the mathematician.

So there you go.

This joke is about you.

 
neverness:

This joke is about you.

hmm, don't know whether to smile or .... If you know a trading terminal that will fulfill all your whims, what's the point? i'm 100% satisfied with MT4/5, i can do everything with it, keep the indicator that draws D1 periods on the chart, if you get interested in programming, modify it to suit your needs ... I don't think you'll be able to do it ....

#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com/ru/users/igorm"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2
//--- plot line1
#property indicator_label1  "Period"
#property indicator_type1   DRAW_HISTOGRAM
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
#property indicator_label2  "Period"
#property indicator_type2   DRAW_HISTOGRAM
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- input parameters
input int      Days=3;
//--- indicator buffers
double         Pmax[],Pmin[];
bool run=true;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,Pmax);
   SetIndexBuffer(1,Pmin);
   run=true;
   switch(_Period)
     {
      case PERIOD_M1:   SetIndexShift(0,1440*Days);SetIndexShift(1,1440*Days);   break;
      case PERIOD_M5:   SetIndexShift(0,288*Days); SetIndexShift(1,288*Days);    break;
      case PERIOD_M15:  SetIndexShift(0,96*Days);  SetIndexShift(1,96*Days);     break;
      case PERIOD_M30:  SetIndexShift(0,48*Days);  SetIndexShift(1,48*Days);     break;
      case PERIOD_H1:   SetIndexShift(0,24*Days);  SetIndexShift(1,24*Days);     break;
      case PERIOD_H4:   SetIndexShift(0,6*Days);   SetIndexShift(1,6*Days);      break;
      default: run=false; SetIndexShift(0,0); SetIndexShift(1,0);ArrayInitialize(Pmax,EMPTY_VALUE);ArrayInitialize(Pmin,EMPTY_VALUE); break;
     }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {
//---
   if(prev_calculated==0)
     {
      run=true;
      ArrayInitialize(Pmax,EMPTY_VALUE);
      ArrayInitialize(Pmin,EMPTY_VALUE);
     }
   if(run)
     {
      int i=0,lastperiod=TimeDay(time[0]);
      double maxvalue;
      if(!ChartGetDouble(ChartID(),CHART_PRICE_MAX,0,maxvalue)) maxvalue=1000.0;
      maxvalue*=10.0;
      while(i<rates_total)
        {
         if(TimeDay(time[i])!=lastperiod)
           {
            lastperiod=TimeDay(time[i]);
            Pmax[i-1]=maxvalue;
            Pmin[i-1]=0.0;
           }
         else
           {
            Pmax[i]=EMPTY_VALUE;
            Pmin[i]=EMPTY_VALUE;
           }
         i++;
        }
      run=false;
     }
//---
   return(rates_total);
  }
//+------------------------------------------------------------------+
Chart EURUSD.e, H1, 2018.11.09 13:11 UTC, RoboForex (CY) Ltd, MetaTrader 4, Demo


i have already tried it and i dont know why, i dont know why, it's the first time i´ve seen it so, it seems that i initialize buffers when i switch timeframes

 
neverness:

Finally I saw the only "constructive answer" to my question in this whole "discussion".

As for the errors, they are present on all separator-weeks in the current (last) frame on both MT4 and MT5.

Everywhere in the last week separator MT4/MT5 draws the separator 7 days instead of 5.

But that is not the point. The errors have always been and will always be. All this may be corrected if there is a program code for drawing delimiters.

It's not the mistakes that surprise me, it's something else entirely.

Has nobody thought of writing a program for drawing delimiters in the predicted area during all the time of MT4/MT5 existence?

After all, the program is the simplest one.

All you need to know is position of the last divider and "solution" of time along X axis (i.e. what time interval takes 1 pixel).

And so far no one has ever ???

Now that really surprises me.

Once again, you'll have to do everything yourself.

I told you - I've done it more than once. (and in the marketplace, and in more than one indicator)

and you said you already wrote the code, will you write it again?)

 
Igor Makanu:

hmm, I don't know whether to smile or .... If you know a trading terminal that will fulfill all your whims, what's the point? I'm 100% satisfied with MT4/5, I can do everything with it, keep the indicator that draws D1 periods on the chart, get interested in programming, modify it to suit your needs ... I don't think you'll be able to do it ....


I would not know why, it's the first time I've seen such a bug.

Thanks, of course.

As I suspected, on incomplete days your period separators don't match the standard ones.

But that's not very important, because I don't think you should try to redraw the standard separators, but rather dock the forecast area separators to the history separators.

Then the position of the incomplete history day delimiters will not affect the forecast delimiters.

Another important difference between your indicator and standard delimiters is that standard delimiters are updated at each event on the chart itself, but your indicator is updated at each OnCalculate() event. I thought this would be noticeable - but in fact it is hardly noticeable.

Of course, this indicator should be redesigned, but thanks anyway. It was interesting to see.

 
Ghabo:

This turns out to be the index of the bar of the object with the specified name. There is more than one object and its name is "QUADRO "+Time[i+1] How do I know that there is no such object on ten bars?

It is clear with the buffer, if the value is empty nothing is shown on the chart, but what about the object?

if (ObjectFind(0,"QUADRO"+Time[10])<0)
        {
        //объекта нет на 10 баре
        }
 
Vitaly Muzichenko:
Can I try it this way?
  int n = Bars(Symbol(), PERIOD_CURRENT, ObjectGetInteger(0,"Rectangle",OBJPROP_TIME,1), TimeCurrent());

Thank you. This turns out to be the bar index (120983) of the object with the specified name. There is more than one object and its name is "QUADRO "+Time[i+1] How do I know that there is no such object on ten bars?

I get it with the buffer, if the value is empty nothing is shown on the chart, but what about the object?